dimanche 11 juin 2017

Datagridview add Checkbox on some cell using

I have a DataGirdView that is bound to a List.

I would like to add CheckBox on some cell by DataGridViewCheckBoxCell, but that is no controllers display on my datagridview. Below is my code:

class ColumnNames
{
    public string Check { get; set; }
    public string Index { get; set; }
    public string SubIndex { get; set; }
    public string Name { get; set; }
    public string Value { get; set; }

    public ColumnNames(
        string Check,
        string Index,
        string SubIndex,
        string Name,
        string Value
        )
    {
        this.Check = Check;
        this.Index = Index;
        this.SubIndex = SubIndex;
        this.Name = Name;
        this.Value = Value;
    }
}

itemsList.Add(new ColumnNames(Check, Index, SubIndex, Name, DataType));
datagridview.DataSource = itemsList;
datagridview.Rows[0].ReadOnly = true;
datagridview.Rows[0].Cells[0] = new DataGridViewCheckBoxCell();
datagridview.Rows[0].Cells[0].Value = false;

when I run this code, I only get the string 'false' on cell[0]. I had monitor this cell using break point, this cell is "Datagirdviewcheckboxcell" , but no checkbox controller on this. How can I solve this problem? Thanks!




Aucun commentaire:

Enregistrer un commentaire