473,324 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

DataGridView Problem with unbound Checkbox cell

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
Dec 3 '06 #1
1 3479
Resolved...

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

"Martin" <@ntlworld.comwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
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

Dec 3 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Mike | last post by:
Hi all, I have a DataGridViewCheckBoxColumn as one of my columns in a DataGridView. I want this checkbox to only be checked, but not unchecked - it's used by the user to audit that they have...
4
by: Hexman | last post by:
Hello All, I'd like to find out the best way to add a cb column to a dgv and process efficiently. I see at least two ways of doing it. ------------------------------- 1) Add a cb to the dgv,...
1
by: sklett | last post by:
I've got a strange situation here. I have a databound DataGridView that also has un-bound columns. When the view loads, I want to update the values of the unbound columns. If I attempt to modify...
2
by: mrstrong | last post by:
Gday, I have a datagridview that I am creating the columns programatically which all seems to work fine. I have a couple of dropdown boxes, so I have set the editMode= EditOnEnter. Now my...
2
by: mrstrong | last post by:
Gday, Why would all my checkboxes inside a datagridview stop working (ie checked state not updating when user clicks) when the datagridview's editmode property is changed to "EditOnEnter"? It...
1
by: zacks | last post by:
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...
2
by: =?Utf-8?B?S2lt?= | last post by:
foreach (DataGridViewRow row in this.dataGridView.Rows) { if (row.Cells.Value.ToString() == "true") { return true; } } return false;
4
by: Benysh | last post by:
Hi everyone. I'm having a really annoying problem I can't solve and couldn't find an answer to anywhere, let's see if you got what it takes. I have a dataGridView on a C# Windows Form. Unbound....
0
by: priyamtheone | last post by:
I'm trying to make a datagridview column to act like a datetimepicker column (C#.Net 2005). These are the behaviours that the dgv should have: 1) Initially all the cells of the dtp column should be...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.