HeaderPane
Main
Hide
Share Link
Print

Add Method, ItemClass Class

Adds a new dependent to the current item. The new item is added as the last dependent.

Class: ItemClass
Namespace: Softelvdm.SftTreeNET
Assembly: Softelvdm.SftTreeNET

Syntax

public ItemClass Add();
public ItemClass Add( string[] CellTexts );
public ItemClass Add( string CellText );
Public Function Add() As ItemClass
Public Function Add( ByVal CellTexts As String() ) As ItemClass
Public Function Add( ByVal CellText As String ) As ItemClass

Parameters

CellTexts

Defines an array of strings added as cell text to the item's cells.

CellText

Defines a string added as cell text to the item's first cell.

Return Value

The new item.

Comments

Adds a new dependent to the current item. The new item is added as the last dependent.

The strings defined by CellTexts are added to the cells of the new item. Each cell of the new item receives one string as a part (TextPartClass). An application can add additional parts to the cells.

The string defined by CellText is added to the first cell of the new item. The cell receives the string as a part (TextPartClass). An application can add additional parts to the cells.

Examples

C# View entire sample code

            sftTree1.Headers[0, 0].Text = "Left Tree Control";
            for (int c = 1; c < sftTree1.Columns.Count; ++c) {
                sftTree1.Headers[0, c].Text = "Column " + c.ToString();
            }
            for (int i = 0; i < 100; ++i) {
                ItemClass itemParent = sftTree1.ItemCollection.Add(new string[] { "Item " + i.ToString(), "Cell 1 in Item " + i.ToString(), "Cell 2 in Item " + i.ToString() } );
                itemParent.RowHeader.Text = i.ToString();
                ++i;
                ItemClass item = itemParent.Add(new string[] { "Item " + i.ToString(), "Cell 1 in Item " + i.ToString(), "Cell 2 in Item " + i.ToString() });
                item.RowHeader.Text = i.ToString();
                ++i;
                ItemClass subitem = item.Add(new string[] { "Item " + i.ToString(), "Cell 1 in Item " + i.ToString(), "Cell 2 in Item " + i.ToString() });
                subitem.RowHeader.Text = i.ToString();
                ++i;
                ItemClass child = subitem.Add(new string[] { "Item " + i.ToString(), "Cell 1 in Item " + i.ToString(), "Cell 2 in Item " + i.ToString() });
                child.RowHeader.Text = i.ToString();

VB.NET View entire sample code

    SftTree1.Headers(0, 0).Text = "Left Tree Control"
    For c As Integer = 1 To SftTree1.Columns.Count - 1
        SftTree1.Headers(0, c).Text = "Column " + c.ToString()
    Next
    For i As Integer = 0 To 100 - 1
        Dim itemParent As ItemClass = SftTree1.ItemCollection.Add(New String() {"Item " + i.ToString(), "Cell 1 in Item " + i.ToString(), "Cell 2 in Item " + i.ToString()})
        itemParent.RowHeader.Text = i.ToString()
        i = i + 1
        Dim item As ItemClass = itemParent.Add(New String() {"Item " + i.ToString(), "Cell 1 in Item " + i.ToString(), "Cell 2 in Item " + i.ToString()})
        item.RowHeader.Text = i.ToString()
        i = i + 1
        Dim subitem As ItemClass = item.Add(New String() {"Item " + i.ToString(), "Cell 1 in Item " + i.ToString(), "Cell 2 in Item " + i.ToString()})
        subitem.RowHeader.Text = i.ToString()
        i = i + 1
        Dim child As ItemClass = subitem.Add(New String() {"Item " + i.ToString(), "Cell 1 in Item " + i.ToString(), "Cell 2 in Item " + i.ToString()})
        child.RowHeader.Text = i.ToString()

See Also ItemClass Class | Classes | SftTree/NET 3.0