Change RecordSelector Style according to the Cell Value in C1TrueDBGrid


Sometimes, developers may want to change the style of their record selector based on the row of selected data. To achieve this, you can utilize the MouseDown event of TrueDBGrid and use the RowSelectorStyle property as given in the below Visual Basic code:

Private Sub C1TrueDBGrid1_MouseDown(sender As Object, e As MouseEventArgs) Handles C1TrueDBGrid1.MouseDown
        Dim row As Integer = C1TrueDBGrid1.RowContaining(e.Y)
        If C1TrueDBGrid1.Columns(col_Index).CellValue(row) < 2 Then
            C1TrueDBGrid1.RowSelectorStyle.BackColor = Color.Red
            C1TrueDBGrid1.RowSelectorStyle.ForeColor = Color.Green
            C1TrueDBGrid1.RowSelectorStyle.BackColor = Color.Blue
            C1TrueDBGrid1.RowSelectorStyle.ForeColor = Color.WhiteSmoke
        End If
 End Sub

Prabhat Sharma