Hide

SftTree/NET 2.0 - Tree Control for Windows Forms

Display
Print

Add Method, ItemCollectionClass Class

Adds a new item at the end of the item collection.

Class: ItemCollectionClass
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 item at the end of the item collection.

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#

             AddItem(cat, img, "Item abc");
                        
            sftTree1.Columns.MakeOptimal(0, false);
            sftTree1.RecalcHorizontalExtent();
            sftTree1.Initializing = false;
        }

        private ItemClass AddCategory(string Category) {
            ItemClass item = sftTree1.ItemCollection.Add();
            CellClass cell = item.Cells[0];
            cell.Appearance = BackgroundAppearanceEnum.ThemedSystemHeaderNeverPressed;
            cell.Parts.Add(new ImagePartClass(m_PlusImage));
            cell.Parts.Add(new TextPartClass(Category));
            item.TagString = "This is a tooltip explaining " + Category;
            return item;
        }

VB.NET

     AddItem(cat, img, "Item abc")

    sftTree1.Columns.MakeOptimal(0, False)
    sftTree1.RecalcHorizontalExtent()
    sftTree1.Initializing = False
End Sub

Private Function AddCategory(ByVal Category As String) As ItemClass
    Dim item As ItemClass = sftTree1.ItemCollection.Add()
    Dim cell As CellClass = item.Cells(0)
    cell.Appearance = BackgroundAppearanceEnum.ThemedSystemHeaderNeverPressed
    cell.Parts.Add(New ImagePartClass(m_PlusImage))
    cell.Parts.Add(New TextPartClass(Category))
    item.TagString = "This is a tooltip explaining " & Category
    Return item
End Function

See Also ItemCollectionClass Class | Classes | SftTree/NET 2.0