Is there a way to change a cell background color in the griddataboundgrid based on data that is bound to it?
If value-in-cell = "A" then cell background = red
If value-in-cell = "B" then cell background = green
Thanks in advance
CBClay Burch Syncfusion Team August 24, 2002 04:30 AM
You can do this in a PrepareViewStyleInfo event which is hit just before the style is used by the drawing code that draws the cell. Changing the style here only affects the visual display, and is not persisted in any manner.
So, try adding a handler for this event and use code such as:
Private Sub GridDataBoundGrid2_PrepareViewStyleInfo(ByVal sender As System.Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs) Handles GridDataBoundGrid2.PrepareViewStyleInfo
If e.Style.Text.StartsWith("A") Then
e.Style.BackColor = Color.Red
ElseIf e.Style.Text.StartsWith("B") Then
e.Style.BackColor = Color.Green