ComponentOne List for WinForms
In This Topic
    Creating and Removing Splits
    In This Topic

    In code, you must create and remove splits using the RemoveHorizontalSplit, InsertHorizontalSplit, RemoveVerticalSplit, and InsertVerticalSplit methods. Each method takes a zero-based split index:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    ' Create a split with index 7.
    Me.C1List1.InsertVerticalSplit(7)
          
    ' Remove the split with index 5.     
    Me.C1List1.RemoveVerticalSplit(5)
    
    

    To write code in C#

    C#
    Copy Code
    // Create a split with index 7.     
    this.c1List1.InsertVerticalSplit[7];
    
    // Remove the split with index 5.
    this.c1List1.RemoveVerticalSplit[5];
    

    You can determine the number of splits in a list using the SplitCollection Count property:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    ' Set variable equal to the number of splits in C1List1.
    variable = Me.C1List1.Splits.Count
    

    To write code in C#

    C#
    Copy Code
    // Set variable equal to the number of splits in C1List1.
    variable = this.c1List1.Splits.Count;
    
    

    You can iterate through all splits using the Count property, for example:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    For n = 0 To Me.C1List1.Splits.Count - 1
        Debug.WriteLine (Me.C1List1.Splits(n).Caption)
    Next n
    

    To write code in C#

    C#
    Copy Code
    for ( n = 0; n <= this.C1List1.Splits.Count   1; i++)
    {
        Console.WriteLine (this.C1List1.Splits[n].Caption);
    }
    

    Of course, a more efficient way to code this would be to use a For Each...Next loop:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Dim S As C1List.Split
    For Each S In Me.C1List1.Splits 
        Debug.WriteLine (S.Caption)
    Next S
    

    To write code in C#

    C#
    Copy Code
    C1List.Split S;
    foreach (S in this.C1List1.Splits)
    {
        Console.WriteLine (S.Caption);
    }
    

    The new Split object will inherit all of its properties from the last object in the collection.