Clear datagridview checkbox column with button click

VB.Net 2005

I need sample code to clear datagridview checkbox column with button click event.
dave_skyAsked:
Who is Participating?
 
Solar_FlareCommented:
ok, so your grid is bound to a table, try this

 For Each r As DataGridViewRow In DataGridView1.Rows
      If Not IsNothing(r.DataBoundItem) Then CType(r.DataBoundItem, DataRowView).Row("columnName") = False
 Next
0
 
Solar_FlareCommented:
if you are wanting to uncheck all the checkboxes then something like this should do it

for each r as DataGridViewRow in datagridview1.rows
   'this next bit depends on the type of object bound to the gridview
r.DataBoundItem

next
0
 
Solar_FlareCommented:
sorry submitted by accident

for each r as DataGridViewRow in datagridview1.rows
   'this next bit depends on the type of object bound to the gridview
   r.DataBoundItem.Item("checkboxcolumn") = False  'if bound to a table
   CType(r.DataBoundItem, objectType).propertyname = False 'if bound to a type of object
next
0
 
dave_skyAuthor Commented:
Solar_Flare,

Doesn't seem to work - locks the form up.

I tried:
r.DataBoundItem.SelectedColumns.Item("checkboxcolumn") = False  'if bound to a table

still doesn't work.



0
 
dave_skyAuthor Commented:
Solar_Flare,

That did the trick.

Thanks,

Dave
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.