Xceed Grid for WinForms v4.3 Documentation
How to create a StyleSheet

Welcome to Xceed Grid for WinForms v4.3 > Task-Based Help > Appearance > How to create a StyleSheet

The appearance of each element in the grid can be customized by setting various properties such as BackColor and ForeColor, however it is also possible to customize the appearance of the entire grid (or just portions) using stylesheets

Although the grid comes with seven predefined stylesheets, it is possible to create your own using the StyleSheet class.

Demonstration

The following code demonstrates how to use one of the predefined stylesheets and apply it to the grid:

VB.NET Copy Code
GridControl1.ApplyStyleSheet( StyleSheet.Xceed )
C# Copy Code
gridControl1.ApplyStyleSheet( StyleSheet.Xceed );

If you want to create your own stylesheet, for example to alternate the color of the datarows in the grid, you could use the following code:

VB.NET Copy Code

Dim styleSheet As New StyleSheet()
Dim style1 As New VisualGridElementStyle()
Dim style2 As New VisualGridElementStyle() 

style1.BackColor = Color.Green
style2.BackColor = Color.Blue 

styleSheet.DataRows.Add(style1)
styleSheet.DataRows.Add(style2) 

' Don't forget to call the grid's ApplyStyleSheet method so that the new styles are reflected
' in the grid.
GridControl1.ApplyStyleSheet(styleSheet)

C# Copy Code

StyleSheet styleSheet = new StyleSheet();
VisualGridElementStyle style1 = new VisualGridElementStyle();
VisualGridElementStyle style2 = new VisualGridElementStyle(); 

style1.BackColor = Color.Green;
style2.BackColor = Color.Blue; 

styleSheet.DataRows.Add( style1 );
styleSheet.DataRows.Add( style2 ); 

// Don't forget to call the grid's ApplyStyleSheet method so that the new styles are reflected
// in the grid.
gridControl1.ApplyStyleSheet( styleSheet );

Of course there are various other elements that you can customize using stylesheets, so your best option is to play around with them to get the desired appearance.