ComponentOne List for WinForms
In This Topic
    Adding Members
    In This Topic

    To create and add an object to a collection, use the collection's Add method. The method takes an object as its only argument. For example, you can create more valueitems for a column by adding new ValueItem objects to the ValueItemCollection object:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    ' Create a ValueItem object.
    Dim S As New C1List.ValueItem  
    Me.C1List1.Columns(0).ValueItems.Values.Add(S)
    

    To write code in C#

    C#
    Copy Code
    // Create a ValueItem object.
    C1List.ValueItem S;     
    this.c1List1.Columns[0].ValueItems.Values.Add(S);
    

    This code adds a ValueItem object to the ValueItemCollection of C1List1. Alternatively, you can create a ValueItem object with index 1 with the Insert method:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    ' Create a Split object with index 1.
    Dim S As New C1List.ValueItem  
    Me.C1List1.Columns(0).ValueItems.Values.Insert(1, S)
    

    To write code in C#

    C#
    Copy Code
    // Create a Split object with index 1. 
    C1List.ValueItem S;
    this.c1List1.Columns[0].ValueItems.Values.Insert(1, S);
    

    The only object which is unable to add or remove members using the Add or RemoveAt methods is the Split object. To correctly add or remove Splits you must use the InsertHorizontalSplit/RemoveHorizontalSplit and InsertVerticalSplit/RemoveVerticalSplit methods of the Split object. These methods are also available in the list's right-click context menu at design time