Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In datagridview checkboxcolumn, I should be able to get only checked values, since these are the values I should store in an string array. How can I do this?
Posted
Updated 17-Nov-10 18:19pm
v2

Try This:
For Each dgrow As DataGridViewRow In dgrid.Rows
      If Not IsDBNull(dgrow.Cells("CheckBoxColumnName").Value) Then
         If dgrow.Cells("CheckBoxColumnName").Value = True Then
         --add values to string array
         End if
      End If 
Next
 
Share this answer
 
You need to iterate through the DataGridView rows and for each row, cast the cell in the column of interest to DataGridViewCheckBoxCell and cast the Value to a bool.

Here's sort of an example: http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/31c7a954-1a85-4c38-9e9f-e157d33faf0[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900