Hide

SftTree/NET 2.0 - Tree Control for Windows Forms

Display
Print

Expand Method, ItemClass Class

Expands the item so its dependents become visible.

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

Syntax

public void Expand( ExpandStyleEnum Style );
Public Sub Expand( ByVal Style As ExpandStyleEnum )

Parameters

Style

Defines how the item and its dependents are expanded.

Comments

Expands the item so its dependents become visible.

This method can only be used for items in the item area.

If an item is already expanded when using Expand, the item remains unchanged. It does not make any indirect dependents visible. To make sure that an item's indirect dependents are shown, use the ItemClass.Collapse method first, which collapses the item (and all dependents), followed by Expand. Now all dependents are visible.

Examples

C#

        private void ClickCategory(ItemClass item)
        {
            if (item.Level == 0) {
                bool fWasExpanded = item.Expanded;
                if (fWasExpanded) {
                    item.Collapse(CollapseStyleEnum.All);
                    item.Cells[0].Image = m_PlusImage;
                } else {
                    item.Expand(ExpandStyleEnum.All);
                    item.Cells[0].Image = m_MinusImage;
                }
                item.ScrollIntoView();
            } else {
                // selected an item
            }
        }

VB.NET

Private Sub ClickCategory(ByVal item As ItemClass)
    If item.Level = 0 Then
        Dim fWasExpanded As Boolean = item.Expanded
        If fWasExpanded Then
            item.Collapse(CollapseStyleEnum.All)
            item.Cells(0).Image = m_PlusImage
        Else
            item.Expand(ExpandStyleEnum.All)
            item.Cells(0).Image = m_MinusImage
        End If
        item.ScrollIntoView()
    Else
        ' selected an item
    End If
End Sub

See Also ItemClass Class | Classes | SftTree/NET 2.0