Link to home
Start Free TrialLog in
Avatar of dgb
dgb

asked on

no change-event checkbox in datagridview

I have a datagridview but i can't find the change-event of the checkbox.

Thanks in advance.

Dirk
ASKER CERTIFIED SOLUTION
Avatar of razo
razo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dgb
dgb

ASKER

The cellvaluechanged doesn't fire when a checkbox has been checked/unchecked.
(it does fire when leaving the cell, but that doesn't work for me)

The cellcontentclick is also not working as it should.
When repeatedly click the checkbox i can not ask what the current value is.
Avatar of dgb

ASKER

I've been testing and if i manualy set the checkbox value it seems to go ok

' In the CellContentClick-event
After processing the checked-change i have to execute the following command else it doesn't work.
DataViewGrid.CurrentCell.Value = Not DataViewGrid.CurrentCell.Value

Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
       ' my check box colum is the last grid colum
        If e.ColumnIndex = (Me.DataGridView1.Columns.Count - 1) Then
            If Me.DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = True Then
                Me.DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = False
                MessageBox.Show(Me.DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)
 
            Else
                Me.DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = True
                MessageBox.Show(Me.DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value.ToString())
            End If
 
        End If
    End Sub

Open in new window