954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Checkbox in Datagridview

Hi friends

I am working in vb.net ,there is i have a form in which i have a datagridview,& a column of checkbox in tat datagridview,when this datagridview becomes load, that checkes theb employee is present or absent if present so the check box of that perticular row must be checked true else checked false,for this i did

dim chk as checkbox

if condition that
chk.checked=true
else
chk.checked=false
end if
but it giving me a error message "object refrence not set"

please help me to solve this problem

manoj_582033
Light Poster
39 posts since Nov 2008
Reputation Points: 10
Solved Threads: 2
 

Are you adding checkboxes to datagrid at runtime?

Dim chk As New DataGridViewCheckBoxCell

If condition Then
  chk.Value = True
Else
  chk.Value = False
End If
' Add checkbox control to datagrid
DataGridView1.Item(0, 0) = chk

If not, then

If condition Then
  DataGridView1.Item(0, 0).Value = True
Else
  DataGridView1.Item(0, 0).Value = False
End If

"object reference not set"-error comes from declaring an object dim chk as checkbox but not creating the instance, like dim chk as New checkbox

Teme64
Veteran Poster
1,031 posts since Aug 2008
Reputation Points: 218
Solved Threads: 203
 

How to select AllCheckBoxes in DataGridView1 in.Net 2005

Esrinivas
Newbie Poster
1 post since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

You should start your own thread for new questions. But to quickly answer your question, you want to work with the underlying datasource that is connected to the datagridview. For instance if it is a datatable that is connected, you want to set the table with the boolean column to true

TomW
Posting Whiz
343 posts since Sep 2009
Reputation Points: 84
Solved Threads: 48
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You