Table of Contents

Class TreeViewItem

Namespace
Alternet.UI
Assembly
Alternet.UI.Common.dll

Represents an item (also known as a node) of a TreeView.

public class TreeViewItem : BaseControlItem, IBaseControlItem, IBaseObject
Inheritance
TreeViewItem
Implements

Remarks

The Items collection holds all the child TreeViewItem objects assigned to the current TreeViewItem. You can add or remove a TreeViewItem; when you do this, all child tree items are added or removed. Each TreeViewItem can contain a collection of other TreeViewItem objects.

The TreeViewItem text label is set by setting the Text property explicitly. The alternative is to create the tree item using one of the TreeViewItem constructors that has a string parameter that represents the Text property. The label is displayed next to the TreeViewItem image, if one is displayed.

To display images next to the tree items, assign an ImageList to the ImageList property of the parent TreeView control and assign an Image by referencing its index value in the ImageList property. To do that, set the ImageIndex property to the index value of the Image you want to display in the TreeViewItem.

TreeView items can be expanded to display the next level of child items. The user can expand the TreeViewItem by clicking the expand button, if one is displayed next to the TreeViewItem, or you can expand the TreeViewItem by calling the Expand() method. To expand all the child item levels in the Items collection, call the ExpandAll() method. You can collapse the child TreeViewItem level by calling the Collapse() method, or the user can press the expand button, if one is displayed next to the TreeViewItem. You can also call the Toggle() method to alternate between the expanded and collapsed states.

Constructors

TreeViewItem()

Initializes a new instance of the TreeViewItem class with default values.

TreeViewItem(string)

Initializes a new instance of the TreeViewItem class with the specified item text.

TreeViewItem(string, int?)

Initializes a new instance of the TreeViewItem class with the specified item text and the image index position of the item's icon.

Properties

BackgroundColor

Gets or sets background color of the item.

Handle

Gets or sets item handle

HasItems

Gets whether there are any items in the Items list.

ImageIndex

Gets or sets the index of the image that is displayed for the item.

Index

Gets the position of the tree item in the tree item collection.

IsBold

Gets or sets whether item is shown in bold font.

IsExpanded

Gets a value indicating whether the tree item is in the expanded state.

IsFocused

Gets or sets a value indicating whether the tree item is in the focused state.

IsSelected

Gets a value indicating whether the tree item is in the selected state.

Items

Gets the collection of child TreeViewItem of the current tree item.

NextOrPrevSibling

Gets next sibling if item is not the last one, otherwise gets previous sibling. If item has no siblings, Parent is returned.

Parent

Gets the parent tree item of the current item.

ParentItems

Gets items from the TreeView (if item is on root level) or from the Parent (if item has parent).

Text

Gets or sets the text of the item.

TextColor

Gets or sets text color of the item.

TreeView

Gets the owner TreeView that the tree item is assigned to.

Methods

Assign(TreeViewItem, bool)

Assigns properties from another TreeViewItem.

BeginLabelEdit()

Initiates the editing of the tree item label.

Clone(bool)

Creates copy of this TreeViewItem.

Collapse()

Collapses the tree item.

CollapseAll()

Collapses this TreeViewItem and all the child tree items.

EndLabelEdit(bool)

Ends the editing of the tree item label.

EnsureVisible()

Ensures that the tree item is visible, expanding tree items and scrolling the tree view control as necessary.

Expand()

Expands the tree item.

ExpandAll()

Expands this TreeViewItem and all the child tree items.

Remove()

Removes the current tree item from the tree view control.

ScrollIntoView()

Scrolls the item into view.

ToString()

Returns a string that represents the current object.

Toggle()

Toggles the tree item to either the expanded or collapsed state.