el_teedee
Messages postés497Date d'inscriptionmercredi 7 juillet 2004StatutMembreDernière intervention13 juillet 20159 8 juil. 2005 à 10:01
Je file mon code pour ceux que ça intéresse :
// Create a new ListView control.
ListView listView1 = new ListView();
listView1.Bounds = new Rectangle(new Point(100,100), new Size(600,200));
// Set the view to show details.
listView1.View = View.Details;
// Allow the user to edit item text.
listView1.LabelEdit = true;
// Allow the user to rearrange columns.
listView1.AllowColumnReorder = true;
// Display check boxes.
listView1.CheckBoxes = true;
// Select the item and subitems when selection is made.
listView1.FullRowSelect = true;
// Display grid lines.
listView1.GridLines = true;
// Sort the items in the list in ascending order.
listView1.Sorting = SortOrder.Ascending;
// Ici, j'ai un tableau de string[x,5] qui
contient en [x,0] le nom de l'objet, et le reste, ce sont les
propriétés à mettre dans les colonnes, c'est-à-dire les subitems.
// Je crée une collection d'item de la taille du nombre de lignes du tableau (tableau.length / 5) :
ListViewItem[] col_lvi = new ListViewItem[tableau.Length / 5];
for (int i=0; i<tableau.Length / 5;i++)
{
// je remplit l'item en cours par le nom de l'objet
col_lvi[i] = new
ListViewItem(tableau[i,0].Remove(0,19));
for (int j=1; j<5 ;j++)
{
// Je remplit les colonnes de l'item par les propriétés de l'objet
col_lvi[i].SubItems.Add(tableau[i,j]);
}
}
// Create columns for the items and subitems.
listView1.Columns.Add("Nom du fichier", -2, HorizontalAlignment.Left);