ComponentOne List for WinForms
In This Topic
    Selecting Columns
    In This Topic

    If the AllowColSelect property is True, the user can select an individual column or a range of columns with the mouse. Nonadjacent column selections are not supported.

    When the user points to the header of an unselected column, the mouse pointer changes to a down arrow to indicate that the column can be selected.

    When the user clicks a column header, that column is selected and highlighted, and any columns or rows that were previously selected are deselected.

    The user can select a range of columns using either of the following methods:

    1. After selecting the first column in the range by clicking its header, the user can select the last column in the range by holding down the Ctrl or Shift key and clicking another column header. If necessary, the horizontal scroll bar can be used to bring additional columns into view.
    2. Alternatively, the user can hold and drag the mouse pointer within the column headers to select multiple columns.

    In order to manipulate the columns which have been selected at run-time, you will have to query the SelectedColumnCollection. This is a collection of all the C1DataColumn objects for the selected columns. For instance if you select columns 5 through 10, the SelectedColumnCollection will have six members, each a C1DataColumn object. This feature enables you to directly alter the display properties of the column. Using the Item property to access the C1DisplayColumn properties, the code to change the forecolor to red for the first column selected would be:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Dim dc as C1List.C1DataColumn   
    dc = Me.C1List1.SelectedCols(0)  
    Me.C1List1.Splits(0).DisplayColumns.Item(dc).Style.ForeColor = System.Drawing.Color.Red
    

    To write code in C#

    C#
    Copy Code
    C1List.C1DataColumn dc; 
    dc = this.c1List1.SelectedCols[0]; 
    this.c1List1.Splits[0].DisplayColumns[dc].Style.ForeColor = System.Drawing.Color.Red;
    

    You can prevent a column selection from occurring at run time by setting the Cancel argument to True in the list's SelectionChanging event.