[RESOLVED] [2005] Check all checkboxes in datagridview
Hi guys,
I have a datagridview and i import a worlsheet from a selected spreadsheet. All the data is imported to the datagridview. I have created a separate column at runtime which has checkboxes so that the user can select which rows they want.
Now I was wondering whether it was possible to create a button that will check all the checkboxes in the datagridview if the user either wants all the rows selected or a vast majority of them (so they can unselect the ones they dont want)?
I've been searching for the past hour or so and cant find anythin to help me so can anybody out there offer me something that might work?
Thanks in advance :afrog:
Re: [2005] Check all checkboxes in datagridview
The Value of a DataGridViewCheckBoxCell is a Boolean value, so True is checked and False is unchecked. You need to loop through the rows of the grid and set the Value of the appropriate cell to True or False. For instance, if the boolean column is at index 4:
VB Code:
For Each row As DataGridViewRow In myDataGridView.Rows
row.Cells(4).Value = True
Next row
Re: [2005] Check all checkboxes in datagridview
Thanks works perfectly. :wave: