mercredi 29 juin 2016

C# - How to add checkbox at specific row and column?

I want to add checkbox in a specific row and column but i'm always stumbled upon this error

"System.FormatException: Formatted value of the cell has a wrong type."

And here is my code to add the checkbox;

    private void checkboxSource(string columnSource, int n)
    {
        DataGridViewCheckBoxCell checkboxColumn = new DataGridViewCheckBoxCell();
        checkboxColumn.FalseValue = "0";
        checkboxColumn.TrueValue = "1";
        dataGridView1.Rows[n].Cells[6] = checkboxColumn;
    }

I know something is wrong when i try to bind checkboxColumn to datagridview. Can someone please guide me on how to bind the checkbox to datagridview properly provided which row and cell are taken into account. Thank you in advance.




Aucun commentaire:

Enregistrer un commentaire