Category / Section
How to apply row styles to the WinForms GridGroupingControl?
1 min read
Row style
There is no RowStyles property in the GridGroupingControl similar to the GridControl. You can apply styles to a row by using the QueryCellStyleInfo event. Set the e.Style property there when the e.TableCellIdentity points to the Record that you want to set the style on.
C#
//Event triggering. this.gridGroupingControl1.QueryCellStyleInfo += gridGroupingControl1_QueryCellStyleInfo; void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) { // Applies style to the second record row. int recordindex =this.gridGroupingControl1.TableControl.TopRowIndex + 1; if(e.TableCellIdentity.RowIndex==recordindex) { e.Style.ReadOnly = true; e.Style.BackColor = Color.LightCoral; } }
VB
'Event triggering. Private Me.gridGroupingControl1.QueryCellStyleInfo += AddressOf gridGroupingControl1_QueryCellStyleInfo Private Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs) 'Applies style to the second record row. Dim recordindex As Integer =Me.gridGroupingControl1.TableControl.TopRowIndex + 1 If e.TableCellIdentity.RowIndex=recordindex Then e.Style.ReadOnly = True e.Style.BackColor = Color.LightCoral End If End Sub
The output is displayed as follows:
Samples:
C#: RowStyle-C#
VB: RowStyle-VB