3
Answers

Data Grid - Setting a checkbox value

New ToCS

New ToCS

18y
8.7k
1

I have a datagrid in which the very first column is a checkbox. When the user clicks on the checkbox, I want the datagrid to immediately recognize the click and uncheck it if it is already checked and check it if it is not checked alredy. (Data grid recognizes only the second click.)

I want to do this in C#. Anybody have any ideas how to do this?

I also want to know how to make the rest of the columns in this datagrid readonly. The rest of the columns are from the database. The check box I have added using something like this.

DataColumn sChk = new DataColumn("Select");

sChk.DataType = System.Type.GetType("System.Boolean");

sChk.DefaultValue = false;

DataTable1.Columns.Add(sChk);

If I try to do the same using DataGridTableStyles, I was getting a lot of problems, but that allows setting a column to readonly, I think.

I also want to know how to suppress addition of new rows in the grid.

I would greatly appreciate your help.

Please let me knowhow to solve the above problems.

Thanks!

Answers (3)