Check Datagridview check box value

konkanb

New member
Joined
Nov 22, 2009
Messages
1
Programming Experience
1-3
Folks, I created a simple table in access. Col1 is number (default=0), col2 is date/time, col3 is number (default=0) col4 is text.
Using Studio 2005, I created a Windows project and added a DataGridView, connecting to the access database.
This added 2 components: the xxbindingsource and the xxtableadapter.
While clicked on the DataGridView, I right clicked on the DataGridView and selected Edit columns.
For col1 and col3, in the DESIGN/Column Type section, changed it to be a DataGridViewCheckBoxColumn so the user sees these as check box items on the form.
My intention: when the user clicks on the checkbox in col1 populate col2 with the date/time stamp of this action and display on the form.
question 1: Don't know if I am on the right track. Should I define the access fields as a yes/no instead of a number? In that case I guess I will not need to change the DESIGN/Column Type section.
question 2: I am new to the .net world and kind of confused on how to access col1 from the datagridview (since I have 2 fields col1 and col3 that are both "check boxes") and which is the most appropriate event to use to verify if col1 is checked to populate col2 with the date/time stamp of when col1 was checked.
Any assistance will be greatly appreciated.
 
All databases will have a data type dedicated to storing boolean data, i.e. true/false values. In Access it's a Yes/No column. You should ALWAYS use the most appropriate data type for the data you're storing. If you're storing boolean data then you should definitely use Yes/No column. There is no reason not to.

The Value property of a DataGridViewCheckBoxCell contains True or False. If you want to do something when that cell value changes then you would handle the CellValueChanged event of the grid. You can determine which cell from the 'e' parameter and decide what to do from there.
 
Back
Top