DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   VB.NET (http://www.daniweb.com/forums/forum58.html)
-   -   Checkbox in Datagridview (http://www.daniweb.com/forums/thread162691.html)

manoj_582033 Dec 17th, 2008 5:44 am
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

Teme64 Dec 17th, 2008 9:39 am
Re: Checkbox in Datagridview
 
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

Esrinivas Oct 19th, 2009 6:01 am
How to select AllCheckBoxes in DataGridView1 in.Net 2005

TomW Oct 19th, 2009 11:17 am
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


All times are GMT -4. The time now is 9:47 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC