Link to home
Start Free TrialLog in
Avatar of David Svedarsky
David SvedarskyFlag for United States of America

asked on

Clear datagridview checkbox column with button click

VB.Net 2005

I need sample code to clear datagridview checkbox column with button click event.
Avatar of Solar_Flare
Solar_Flare

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
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
Avatar of David Svedarsky

ASKER

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.



ASKER CERTIFIED SOLUTION
Avatar of Solar_Flare
Solar_Flare

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Solar_Flare,

That did the trick.

Thanks,

Dave