Customization / Highlight Related Data
Highlight Related Data

You can change the list's display to highlight rows by creating row styles. This enables you to draw user's attention to specific data in the list.

In the following image, the list items for which the value of "Discontinued" field is "0" have been highlighted in the List control.

 Highlight related data

To highlight data in the List, you can set FetchRowStyles property of the C1List class to true. This property fires the FetchRowStyle event whenever the list is about to display a row of data.

The following example demonstrates how to create style characteristics and apply them to rows dynamically using the FetchRowStyle event.

  1. Set the FetchRowStyles property to true and subscribe to the FetchCellStyle event.
    C#
    Copy Code
    //set FetchRowStyles to true
    c1List1.FetchRowStyles = true;
    //hanlde FetchRowStyle event
    c1List1.FetchRowStyle += C1List1_FetchRowStyle;
    
  2. Add the following code to the C1List1_FetchRowStyle event handler to highlight data based on specific conditions.
    C#
    Copy Code
    private void C1List1_FetchRowStyle(object sender, C1.Win.List.FetchRowStyleEventArgs e)
    {
        //check if the item is discontinued
        var discontinued = int.Parse(c1List1.Columns["Discontinued"].CellText(e.Row));
        if (discontinued != 0)
            //highlight if not discontinued
            e.CellStyle.ForeColor = Color.Blue;
    }