Click here to Skip to main content
15,848,319 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
How to checked a checkbox in datagridview if we access data from db into ds according to value i want to change the check state of the check box in data gridview..
pls help
Uday P.Singh 11-Jul-11 4:00am    
what are you trying to do? your question is not clear..
advancedansh 11-Jul-11 4:48am    
act i have a data grid view in which i have a check box ..
and i have a data base table in which one coloumn name is select which is boolean type i m accessing the table value in data set if select value is true i want to checked the check box automatically pls help
Uday P.Singh 12-Jul-11 7:07am    
as Raju said if you are showing the data in gridview and database table field is Boolean then you don't have to do anything, it will show the checkbox and also display checked if its true.
Raju Prajapati 12-Jul-11 5:45am    
if you are putting yourdatagridview.datasource=ds.table["table_name"], the checkbox for boolean with checked or unchacked will come itself.
advancedansh 13-Jul-11 0:23am    
thanks friend..
but i tried but its nt working

1 solution

Hope I am not misunderstanding your needs here but...

Providing your cell is a DataGridViewCheckBoxCell you can do the following things...

To Set:

dataGridView.Rows[0].Cells[0].Value = true;

To Read:

bool checked = (bool)dataGridView.Rows[0].Cells[0].Value;

To Evaluate:

   //Do Something

NOTE: If you are reading a checkbox cells upon save you may want to add the following code to a CellMouseUp event on your DataGridView:

void DataGridViewCellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
Share this 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