| List for WinForms Tutorials > Tutorial 10 - Using Row Styles to Highlight Related Data |
In this tutorial, you will learn how to change the list's display to highlight rows by creating row styles depending upon a value in the list. C1List uses the FetchRowStyle event to create style characteristics and apply them to rows dynamically.

To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Dim bFlag1, bFlag2 As Boolean |
|
To write code in C#
| C# |
Copy Code
|
|---|---|
bool bFlag1, bFlag2; |
|
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Me.C1List1.FetchRowStyles = True bFlag1 = True Me.C1List1.Refresh() |
|
To write code in C#
| C# |
Copy Code
|
|---|---|
this.c1List1.FetchRowStyles = true; bFlag1 = true; this.c1List1.Refresh(); |
|
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Me.C1List1.FetchRowStyles = True bFlag2 = True Me.C1List1.Refresh() |
|
To write code in C#
| C# |
Copy Code
|
|---|---|
this.c1List1.FetchRowStyles = true; bFlag2 = true; this.c1List1.Refresh(); |
|
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Me.C1List1.FetchRowStyles = True bFlag1 = False bFlag2 = False Me.C1List1.Refresh() |
|
To write code in C#
| C# |
Copy Code
|
|---|---|
this.c1List1.FetchRowStyles = true; bFlag1 = false; bFlag2 = false; this.c1List1.Refresh(); |
|
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Private Sub C1List1_FetchRowStyle(ByVal sender As Object, ByVal e As C1.Win.C1List.FetchRowStyleEventArgs) Handles C1List1.FetchRowStyle
If (bFlag1 And Me.C1List1.Columns("CustType").CellValue(e.Row) = 1) Then
Dim fntFont As New Font(e.CellStyle.Font.Name, e.CellStyle.Font.Size, FontStyle.Bold)
e.CellStyle.Font = fntFont
e.CellStyle.ForeColor = Color.Blue
End If
If (bFlag2 And Me.C1List1.Columns("CustType").CellValue(e.Row) = 4) Then
e.CellStyle.ForeColor = Color.White
e.CellStyle.BackColor = Color.Red
End If
End Sub
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
private void C1List1_FetchRowStyle( object sender, C1.Win.C1List.FetchRowStyleEventArgs e)
{
if (bFlag1 && this.c1List1.Columns["CustType"].CellValue(e.Row) == 1)
{
Font fntFont = new Font(e.CellStyle.Font.Name, e.CellStyle.Font.Size, FontStyle.Bold);
e.CellStyle.Font = fntFont;
e.CellStyle.ForeColor = Color.Blue;
}
if (bFlag2 && this.c1List1.Columns["CustType"].CellValue(e.Row) == 4)
{
e.CellStyle.ForeColor = Color.White;
e.CellStyle.BackColor = Color.Red;
}
}
|
|


This concludes the tutorial.