DataGridView CheckBox Cell


Z

zacks

Using VS 2005.

I have an app that has a DataGridView control. This control has two
columns, the first column is a standard TextBox, and the second column
is a CheckBox.

I am having difficulty determining the state of the CheckBox, whether
it is checked or not. I have identified an event that fires when the
user clicks in the checkbox, CellClick. In that event handler I
declare a local variable of the DataGridViewCheckBoxCell type and set
it to the cell that fired the event with a statement like this:

DataGridViewCheckBoxCell chk;

if (e.ColumnIndex == 1)
chk = datagridview.Rows[e.RowIndex].Cells[e.ColumnIndex];

But the chk.Value property is ALWAYS set whether the checkbox is
checked or not!!!

I have searched the help files but cannot find anything on how to
handle ANY of the DataGridView special cell types. How do I determine
the state of this checkbox cell?

TIA,
 
Ad

Advertisements

C

Chris Shepherd

Using VS 2005.

I have an app that has a DataGridView control. This control has two
columns, the first column is a standard TextBox, and the second column
is a CheckBox.

I am having difficulty determining the state of the CheckBox, whether
it is checked or not. I have identified an event that fires when the
user clicks in the checkbox, CellClick. In that event handler I
declare a local variable of the DataGridViewCheckBoxCell type and set
it to the cell that fired the event with a statement like this:
[...]

According to the docs
(http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridviewcheckboxcell.aspx)
the value will be either True or False when in simple on/off (binary) mode.

Chris.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top