Bonjour à tout le monde,
j'ai un datagridview dans un "classe component"; J'affecte à datasource de datagridview un datatable.
voila mon code:
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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 
 
this.DataGridView1.DataSource = CreateDataTable();
 
 
private DataTable CreateDataTable()
        {
            DataTable dtable = new DataTable("Rock");
            //set columns names
            dtable.Columns.Add("Band", typeof(System.String));
            dtable.Columns.Add("Song", typeof(System.String));
            dtable.Columns.Add("Album", typeof(System.String));
 
            //Add Rows
            DataRow drow = dtable.NewRow();
            drow["Band"] = "Iron Maiden";
            drow["Song"] = "Wasted Years";
            drow["Album"] = "Ed Hunter";
            dtable.Rows.Add(drow);
 
            drow = dtable.NewRow();
            drow["Band"] = "Metallica";
            drow["Song"] = "Enter Sandman";
            drow["Album"] = "Metallica";
            dtable.Rows.Add(drow);
 
            drow = dtable.NewRow();
            drow["Band"] = "Jethro Tull";
            drow["Song"] = "Locomotive Breath";
            drow["Album"] = "Aqualung";
            dtable.Rows.Add(drow);
 
            drow = dtable.NewRow();
            drow["Band"] = "Mr. Big";
            drow["Song"] = "Seven Impossible Days";
            drow["Album"] = "Japandemonium";
            dtable.Rows.Add(drow);
 
            return dtable;
        }
Le problème que le datagridview n'affiche aucun ligne.

ma question: comment on peut résoudre ce problème ?