ComponentOne List for WinForms
In This Topic
    Moving Columns at Run Time
    In This Topic

    If the AllowColMove property is True, users can move columns at run-time. 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 common place collection methods of RemoveAt and Insert help accomplish this quite easily. The following code will transpose the first two columns in the default split:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Dim dc as C1List.C1DisplayColumn  
    dc = Me.C1List1.Splits(0).DisplayColumns.Item(1)     
    Me.C1List1.Splits(0).DisplayColumns.RemoveAt(1)  
    Me.C1List1.Splits(0).DisplayColumns.Insert(0, dc)
    

    To write code in C#

    C#
    Copy Code
    C1List.C1DisplayColumn dc;
    dc = this.c1List1.Splits[0].DisplayColumns[1];  
    this.c1List1.Splits[0].DisplayColumns.RemoveAt(1);
    this.c1List1.Splits[0].DisplayColumns.Insert(0, dc);