Bonjour,
Mon programme rempli un DataGridView au travers de la méthode ci-contre. Le problème, c'est que jai toujours un enregistrement (ligne) de trop. J'ai essayé d'autres façons comme en ajoutant la ligne après avoir actualisé la ligne présente mais dans ce cas, je n'obtenais que la dernière ligne dans le DataGridView. Notez que je dois insérer une image. EN liant un DataTable au DataGridView, je n'étais jamais capable d'insérer l'image. C'est pourquoi j'ai opté pour cette manière de faire.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public void fillDatagridView2(List<Dictionary<string, string>> myList) { dataGridView2.Visible = true; for (int i = 0; i < myList.Count; i++) { dataGridView2.Rows.Add(); dataGridView2.Rows[i].Cells[0].Value = myList[i]["PK_IdItem"]; dataGridView2.Rows[i].Cells[1].Value = (Image)Bitmap.FromFile(myList[i]["location"]); dataGridView2.Rows[i].Cells[2].Value = myList[i]["name"]; dataGridView2.Rows[i].Cells[3].Value = myList[i]["description"]; dataGridView2.Rows[i].Cells[4].Value = myList[i]["price"]; dataGridView2.Rows[i].Cells[5].Value = myList[i]["location"]; dataGridView2.Rows[i].Cells[6].Value = myList[i]["isOriginal"]; dataGridView2.Rows[i].Cells[7].Value = myList[i]["planName"]; dataGridView2.Rows[i].Cells[8].Value = myList[i]["originalItem"]; } }
Partager