If the AllowColMove property is True, the user can move columns at run time also. Since there is no order property for a C1DisplayColumn the C1DisplayColumnCollection needs to be manipulated to move a column at run time. The C1DisplayColumnCollection holds all of the columns in a split. So to move a column, the user needs to remove the C1DisplayColumn from the collection, and then replace the column in the new position. The commonplace collection methods of RemoveAt and Add help accomplish this quite easily. The code which would transpose the first two columns in the default split would look as follows:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Dim dc as C1TrueDBGrid.C1DisplayColumn dc = Me.C1TrueDBGrid1.Splits(0).DisplayColumns(1) Me.C1TrueDBGrid1.Splits(0).DisplayColumns.RemoveAt(1) Me.C1TrueDBGrid1.Splits(0).DisplayColumns.Insert(0, dc) |
To write code in C#
C# |
Copy Code
|
---|---|
dc as C1TrueDBGrid.C1DisplayColumn; dc = this.c1TrueDBGrid1.Splits(0).DisplayColumns[1]; this.c1TrueDBGrid1.Splits[0].DisplayColumns.RemoveAt(1); this.c1TrueDBGrid1.Splits[0].DisplayColumns.Insert(0, dc); |