ComponentOne True DBGrid for .NET (2.0) Search HelpCentral 

Moving Columns at Run Time

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 DisplayColumn 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:

·      Visual Basic

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)

·      C#

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);

·      Delphi

var dc: C1TrueDBGrid.C1DataColumn;

 

dc := Self.C1TrueDBGrid1.Splits[0].DisplayColumns.Item[1];

Self.C1TrueDBGrid1.Splits[0].DisplayColumns.RemoveAt(1);

Self.C1TrueDBGrid1.Splits[0].DisplayColumns.Insert(0, dc);


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.