DataGridView CheckBox Cell

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • zacks@construction-imaging.com

    #1

    DataGridView CheckBox Cell

    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 DataGridViewChe ckBoxCell type and set
    it to the cell that fired the event with a statement like this:

    DataGridViewChe ckBoxCell chk;

    if (e.ColumnIndex == 1)
    chk = datagridview.Ro ws[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,

  • Chris Shepherd

    #2
    Re: DataGridView CheckBox Cell

    zacks@construct ion-imaging.com wrote:
    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 DataGridViewChe ckBoxCell 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/lib...ckboxcell.aspx)
    the value will be either True or False when in simple on/off (binary) mode.

    Chris.

    Comment

    Working...