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.
There are two ways for the user to select a range of columns:
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 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 that have been selected at run-time, query the SelectedColumnCollection. This is a collection of all the C1DataColumn objects for the selected columns. For instance, if columns 5 through 10 are selected, the SelectedColumnCollection will have six members, each a C1DataColumn object. This feature enables the display properties of the column to be altered directly. Using the Item property to access the C1DisplayColumn properties, the code to change the forecolor to red for the first column selected would be:
Dim dc as C1TrueDBGrid.C1DataColumn
dc = Me.C1TrueDBGrid1.SelectedCols(0)
Me.C1TrueDBGrid1.Splits(0).DisplayColumns(dc).Style.ForeColor = System.Drawing.Color.Red
· C#
dc as C1TrueDBGrid.C1DataColumn;
dc = this.C1TrueDBGrid1.SelectedCols[0];
this.C1TrueDBGrid1.Splits[0].DisplayColumns[dc].Style.ForeColor = System.Drawing.Color.Red;
· Delphi
var dc: C1TrueDBGrid.C1DataColumn;
dc := Self.C1TrueDBGrid1.SelectedCols[0];
Self.C1TrueDBGrid1.Splits[0].DisplayColumns.Item[dc].Style.ForeColor := System.Drawing.Color.Red;
Prevent a column selection from occurring at run time by setting the Cancel argument to True in the grid's SelChange event.
Send comments about this topic to ComponentOne. Copyright © ComponentOne LLC. All rights reserved. |