ComponentOne List for WinForms
In This Topic
    Tutorial 11 - Displaying Rows in Alternating Colors
    In This Topic

    In this tutorial, you will learn how to use the AlternatingRows property and built-in styles to apply alternating colors to list rows to improve their readability.

    1. Follow steps 1 through 6 of Tutorial 8 - Displaying Translated Data to create a project with a C1List bound to a Data Set.
    2. In the Form_Load event add the following code:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Me.C1List1.AlternatingRows = True
      

      To write code in C#

      C#
      Copy Code
      this.c1List1.AlternatingRows = true;
      

      The list has default settings for both the EvenRow and OddRow styles. We will use the default settings first and then change the settings for the EvenRowStyle.

      Run the program and observe the following:

      C1List1 displays even-numbered rows with a light cyan background.

    3. 3Click the ellipsis button next to the Styles property in the Properties window. This will bring up the Style Collection Editor. Select the EvenRowStyle in the left pane, and in the right pane change its backcolor to LightGray. Click OK and close the editor.

    Run the program and observe the following:

    C1List1 displays data as in the previous figure, except that even-numbered rows now have a light gray background.

    This concludes the tutorial.