RSS Forums RSS

Checkbox in Datagridview

Please support our VB.NET advertiser: DiscountASP.NET – 3 Months Free on VB.NET Web Hosting
Thread Solved
Reply
Posts: 33
Reputation: manoj_582033 is an unknown quantity at this point 
Solved Threads: 0
manoj_582033 manoj_582033 is offline Offline
Light Poster

Checkbox in Datagridview

  #1  
Dec 17th, 2008
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
AddThis Social Bookmark Button
Reply With Quote  
Posts: 650
Reputation: Teme64 is on a distinguished road 
Solved Threads: 106
Teme64's Avatar
Teme64 Teme64 is offline Offline
Practically a Master Poster

Re: Checkbox in Datagridview

  #2  
Dec 17th, 2008
Are you adding checkboxes to datagrid at runtime?
  1. Dim chk As New DataGridViewCheckBoxCell
  2.  
  3. If condition Then
  4. chk.Value = True
  5. Else
  6. chk.Value = False
  7. End If
  8. ' Add checkbox control to datagrid
  9. DataGridView1.Item(0, 0) = chk
If not, then
  1. If condition Then
  2. DataGridView1.Item(0, 0).Value = True
  3. Else
  4. DataGridView1.Item(0, 0).Value = False
  5. 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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Views: 1512 | Replies: 1 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:21 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC