Advertisement
albusmw

Untitled

Feb 12th, 2021
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. Private Sub Button1_Click(sender As Object, e As EventArgs)
  2.  
  3. For ColIdx As Integer = 7 To 22
  4. For RowIdx As Integer = 1 To DataGridView1.Rows.Count - 1 '//angefangen von erster Zeile weil die erste Zeile die Titelzeile ist - ZeilenIndex fangt mit 0 an
  5. If GetBool(DataGridView1.Item(ColIdx, RowIdx).Value) = True Then
  6. DataGridView1.Rows(RowIdx).DefaultCellStyle.BackColor = Color.Red
  7. End If
  8. Next
  9. Next ColIdx
  10.  
  11. End Sub
  12.  
  13. ''' <summary>Get the bool property of the passed object</summary>
  14. ''' <param name="Element">Element to convert</param>
  15. ''' <returns>Boolean property; false is conversion does not work ...</returns>
  16. Private Function GetBool(ByVal Element As Object) As Boolean
  17. If Element.GetType Is GetType(Boolean) Then Return CBool(Element)
  18. If Element.GetType Is GetType(String) Then
  19. If CStr(Element).Trim.ToUpper = "TRUE" Then Return True Else Return False
  20. End If
  21. Return False
  22. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement