Click here to Skip to main content
15,662,823 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

In my project am I using datagridviewcheckbox , I can save this datagridviewcheckbox value in database, Here I want to retrieve the checkbox value in the same datagridviewcheckbox . How Can I do this. For windows application.

Thank You
phil.o 24-Oct-15 3:33am    
Unclear. Please describe more precisely your issue. There is not a single value in a DataGridView; it contains items. So please describe more precisely what you want to do that give you troubles.
George Jonsson 24-Oct-15 3:48am    
Are you using DataTable or DataSet and BindingSource as the layer between your grid and the database?
Mekalamani 24-Oct-15 5:37am    
Thank You
I am using datatable

1 solution

Hi Mekalamani, see the below example,
DataTable objTable = new DataTable();
objTable.Columns.Add("Selection", typeof(bool));

DataRow NewRow1 = objTable.NewRow();
NewRow1["Selection"] = false;

DataRow NewRow2 = objTable.NewRow();
NewRow2["Selection"] = true;


dataGridView1.DataSource = objTable;

Here, when assigning objTable to dataGridView1.DataSource, the DataGridView automatically display the boolean values as checkbox column. Like this, you can make your datatype to bool for your data, which is to be displayed as DataGridViewCheckBoxColumn.
Share this answer
Mekalamani 24-Oct-15 5:40am    
Thank You,

I just want to retrieve the datagridview checkboxcolumn value in the same position.
VR Karthikeyan 24-Oct-15 5:47am    
Same position means what? Just show your code.
Mekalamani 26-Oct-15 1:46am    
I saved the checkbox in checked condition means, when I retrieve the data from backend, the checkbox should be in checked state. Suppose if I saved the checkbox in unchecked condition, while retrieving the data it should be in unchecked condition.
VR Karthikeyan 26-Oct-15 5:20am    
Change your column datatype as bit in the database, it will automatically displayed as checkbox column and automatically saves the checkbox column value as bit in the database, just change column's datatype to bit for the column to which you want to display as checkbox column. This will works.
Mekalamani 26-Oct-15 7:44am    
Thanka for your answer. I got the answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900