Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Clear datagridview checkbox column with button click

Posted on 2007-07-19
5
Medium Priority
?
2,114 Views
Last Modified: 2013-11-26
VB.Net 2005

I need sample code to clear datagridview checkbox column with button click event.
0
Comment
Question by:dave_sky
  • 3
  • 2
5 Comments
 
LVL 15

Expert Comment

by:Solar_Flare
ID: 19527247
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
 
LVL 15

Expert Comment

by:Solar_Flare
ID: 19527266
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
 

Author Comment

by:dave_sky
ID: 19527429
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
 
LVL 15

Accepted Solution

by:
Solar_Flare earned 2000 total points
ID: 19527961
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
 

Author Comment

by:dave_sky
ID: 19528107
Solar_Flare,

That did the trick.

Thanks,

Dave
0

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question