Bonjour,
j'ai un DataGridView lié à une source de donnée et auquel je veux ajouter un DataGridViewCheckBoxColumn.
L'ajout se fait sans probleme, seulement je parvient pas à initialiser les valeurs des cellules correspondant à la colonne CheckBox à true (coché).
Est ce que quelqu un saurait comment faire?
Merci

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
BindingSource sc = new BindingSource();
            DataTable table = Metier.CategorieFormation.getListCategorieFormations().Tables[0];
            table.Columns.Remove("dateCreation");
            table.Columns.Remove("numReg");
            table.Columns.Remove("idRes");
            sc.DataSource = table;
            tblCatForm.DataSource = sc;
            tblCatForm.Columns[0].Visible = false;
            tblCatForm.Columns[1].Width = 300;
            tblCatForm.Columns[1].HeaderText = "Catégories de formation";
 
            DataGridViewCheckBoxColumn col1 = new DataGridViewCheckBoxColumn();
            col1.Width = 25;
            col1.FalseValue = false;
            col1.TrueValue = true;
            col1.ThreeState = false;
            col1.ValueType = Type.GetType("bool");
            tblCatForm.Columns.Insert(0, col1);
 
            for (int i = 0; i < tblCatForm.Rows.Count; i++) {
                tblCatForm.Rows[i].SetValues(true);
            }