Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I load data into the datagridview(LabelDataGrid) I am looking for an asterisk and if it has an asterisk I want the checkbox to be checked(true). I load the data into the datagridview by doing this:

VB
For x1 = 0 To ElCount
      LabelDataGrid.Rows.Add(False, x1, Array(x1, 0), Array(x1, 1), Array(x1, 2), Array(x1, 3), x1)
Next


What I have tried:

When I do this I know that the checkbox value is true because the row that the checkbox is in turns red but the checkbox isn't checked. How Do I fix this?

VB
For x1 = 0 To ElCount
     LabelDataGrid.Rows.Add(False, x1, Array(x1, 0), Array(x1, 1), Array(x1, 2), Array(x1, 3), x1)
      If Array(x1, 0).Contains("*") Then
         LabelDataGrid.Item(x1, 0).Value = True
         If LabelDataGrid.Item(x1, 0).Value = True Then
            LabelDataGrid.Rows(x1).DefaultCellStyle.BackColor = Color.IndianRed
         End If
      End If
Next
Posted
Updated 30-Jun-19 11:45am

1 solution

Edit: I figured out the solution, here it is for anyone that may be having the same problem:

VB
For x1 = 0 To ElCount
   If Array(x1, 0).Contains("*") Then
      LabelDataGrid.Rows.Add(True, x1, Array(x1, 0), Array(x1, 1), Array(x1, 2), Array(x1, 3), x1)
      LabelDataGrid.Rows(x1).DefaultCellStyle.BackColor = Color.IndianRed
   Else
      LabelDataGrid.Rows.Add(False, x1, Array(x1, 0), Array(x1, 1), Array(x1, 2), Array(x1, 3), x1)
   End If
Next
 
Share this answer
 
Comments
Maciej Los 1-Jul-19 4:35am    
Great! Mark your answer as a solution (green button) to remove your question from unanswered list.

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