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

Recommended Answers

All 3 Replies

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

How to select AllCheckBoxes in DataGridView1 in.Net 2005

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.