2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
In order to color a row if the value in column 2 is larger than 10 (or any logical condition that you can evaluate), the PrepareViewStyleInfo event can be used. Code Snippet C# this.gridControl1.Model.Options.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshRow; this.gridControl1.PrepareViewStyleInfo += gridControl1_PrepareViewStyleInfo; void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e) { if (e.RowIndex > 0 && e.ColIndex > 0) { double d; string val = (e.ColIndex == 2) ? e.Style.Text : this.gridControl1[e.RowIndex, 2].Text; if (double.TryParse(val, System.Globalization.NumberStyles.Any, null, out d) && d > 10) { e.Style.BackColor = Color.LightGoldenrodYellow; } } }
VB Me.gridControl1.Model.Options.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshRow AddHandler Me.gridControl1.PrepareViewStyleInfo, AddressOf gridControl1_PrepareViewStyleInfo void gridControl1_PrepareViewStyleInfo(Object sender, GridPrepareViewStyleInfoEventArgs e) If e.RowIndex > 0 AndAlso e.ColIndex > 0 Then Dim d As Double Dim val As String = If((e.ColIndex = 2), e.Style.Text, Me.gridControl1(e.RowIndex, 2).Text) If Double.TryParse(val, System.Globalization.NumberStyles.Any, Nothing, d) AndAlso d > 10 Then e.Style.BackColor = Color.LightGoldenrodYellow End If End If
Screenshot Sample links: |
2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.