DataGridView Problem with unbound Checkbox cell

M

Martin

Hi,

I'm having a problem with a datagridview control when trying to read
the value of an unbound checkbox cell.

The code below works fine if I click on any text cell, bound or unbound,
and also if I click on a data bound checkbox cell.

But it fails with null reference exception if I try to read the value on an
unbound cell.

Can anybody show me where I'm going wrong?

TIA

Martin.

Private Sub InvoicesDataGridView_CellClick(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) _
Handles InvoicesDataGridView.CellClick
' This line works, prints system.boolean
Debug.Print( _
Me.GridView.Rows(e.RowIndex).Cells(e.ColumnIndex).ValueType.ToString)

' This line fails, NullReferenceException
Debug.Print( _
Me.GridView.Rows(e.RowIndex).Cells(e.ColumnIndex).Value.ToString)

End Sub
 
M

Martin

Resolved...

I didn't realise I had to call CommitEdit on the DataGrid before
trying to read the checkbox value.
 

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