Can't find what you're looking for?

Contact us or post in our forums and we'll help you find an answer.

Keep the selected cell highlighted when the C1TrueDBGrid loses focus

Background:

How to keep the selected cell highlighted when the C1TrueDBGrid loses focus.

Steps to Complete:

1. Set the MarqueeStyle of TrueDBGrid to MarqueeEnum.HighlightCell and OwnerDraw to True for all columns:

C1TrueDBGrid1.MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.HighlightCell
For i As Integer = 0 To C1TrueDBGrid1.Splits(0).DisplayColumns.Count - 1   C1TrueDBGrid1.Splits(0).DisplayColumns(i).OwnerDraw = True
Next

2. Handle the OwnerDrawCell event as given below:

Private Sub C1TrueDBGrid1_OwnerDrawCell(sender As Object, e As C1.Win.C1TrueDBGrid.OwnerDrawCellEventArgs) Handles C1TrueDBGrid1.OwnerDrawCell
If C1TrueDBGrid1.Row = e.Row AndAlso C1TrueDBGrid1.Col = e.Col Then
e.Style.BackColor = C1TrueDBGrid1.HighLightRowStyle.BackColor
e.Style.ForeColor = C1TrueDBGrid1.HighLightRowStyle.ForeColor
 End If
End Sub
Get the Latest Version of WinForms Edition
Download the Free Trial Now