# TreeView

Namespace: **Wisej.Web**

Assembly: **Wisej.Framework** (2.5.0.0)

* [Control](/api/v2.5/wisej.web/general/control.md)
  * [TreeView](/api/v2.5/wisej.web/lists-and-grids/treeview.md)

Displays a hierarchical collection of labeled items, each represented by a [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md).

{% tabs %}
{% tab title="C#" %}

```csharp
public class TreeView : Control
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class TreeView
    Inherits Control
```

{% endtab %}
{% endtabs %}

## Constructors

### ![](/files/-MTRl851gGvQXMvSEG1f)TreeView()

Initializes a new instance of the [TreeView](/api/v2.5/wisej.web/lists-and-grids/treeview.md) class.

## Properties

### ![](/files/-MTRl851gGvQXMvSEG1f)BorderStyle

[BorderStyle](/api/v2.5/wisej.web/enumerations/wisej.web.borderstyle.md): Gets or sets the border style of the tree view control.

### ![](/files/-MTRl851gGvQXMvSEG1f)CheckBoxes

[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean): Returns or sets whether check boxes are displayed next to the tree nodes in the tree view control. Tree nodes may override this property setting the [CheckBox](/api/v2.5/wisej.web/lists-and-grids/treeview.md) property.

### ![](/files/-MTRl851gGvQXMvSEG1f)HideNodeImages

[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean): Returns or sets whether all the node images are hidden. Tree nodes may override this property setting the [HideNodeImage](/api/v2.5/wisej.web/lists-and-grids/treeview.md) property.

### ![](/files/-MTRl851gGvQXMvSEG1f)ImageIndex

[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32): Returns or sets the image-list index value of the default image that is displayed by the tree nodes.

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception) The specified index is less than -1.

### ![](/files/-MTRl851gGvQXMvSEG1f)ImageKey

[String](https://docs.microsoft.com/en-us/dotnet/api/system.string): Returns or sets the key of the default image for each node in the [TreeView](/api/v2.5/wisej.web/lists-and-grids/treeview.md) control when it is in an unselected state.

### ![](/files/-MTRl851gGvQXMvSEG1f)ImageList

[ImageList](/api/v2.5/wisej.web/content/imagelist.md): Returns or sets the [ImageList](/api/v2.5/wisej.web/content/imagelist.md) that contains the [Image](https://docs.microsoft.com/en-us/dotnet/api/system.drawing.image) objects that are used by the tree nodes.

### ![](/files/-MTRl851gGvQXMvSEG1f)Indent

[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32): Returns or sets the distance in pixels to indent each child tree node level.

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception) The assigned value is less than -1; or the assigned value is greater than 500.

### ![](/files/-MTRl851gGvQXMvSEG1f)ItemHeight

[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32): Gets or sets the height of each tree node in the tree view control. When the value is -1, uses the value set in the theme.

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception) The assigned value is less than -1; or the assigned value is greater than 500.

### ![](/files/-MTRl851gGvQXMvSEG1f)LabelEdit

[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean): Returns or sets whether the label text of the tree nodes can be edited.

### ![](/files/-MTRl851gGvQXMvSEG1f)Nodes

[TreeNodeCollection](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenodecollection.md): Returns the collection of tree nodes that are assigned to the tree view control.

### ![](/files/-MTRl851gGvQXMvSEG1f)OpenedImageIndex

[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32): Returns or sets the image list index value of the image that is displayed when a [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md) is expanded.

**Throws:**

* [ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception) The index assigned value is less than -1.

### ![](/files/-MTRl851gGvQXMvSEG1f)OpenedImageKey

[String](https://docs.microsoft.com/en-us/dotnet/api/system.string): Returns or sets the key of the default image shown when a [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md) is expanded.

### ![](/files/-MTRl851gGvQXMvSEG1f)PathSeparator

[String](https://docs.microsoft.com/en-us/dotnet/api/system.string): Returns or sets the delimiter string that the tree node path uses.

### ![](/files/-MTRl851gGvQXMvSEG1f)PrefetchItems

[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32): Returns or sets the number of items to prefetch outside of the visible area when [VirtualScroll](#virtualscroll) is set to true. The default is 0 (disabled).

### ![](/files/-MTRl851gGvQXMvSEG1f)RightClickSelection

[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean): Returns or sets whether the [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md) under the pointer gets selected on a right click.

When the right click lands outside of a selected area the selection is not changed regardless of the value of [RightClickSelection](#rightclickselection).

### ![](/files/-MTRl851gGvQXMvSEG1f)Scrollable

[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean): Returns or sets whether the tree view control displays scroll bars when they are needed.

### ![](/files/-MTRl851gGvQXMvSEG1f)SelectedImageIndex

[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32): Returns or sets the image list index value of the image that is displayed when a [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md) is selected.

**Throws:**

* [ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception) The index assigned value is less than -1.

### ![](/files/-MTRl851gGvQXMvSEG1f)SelectedImageKey

[String](https://docs.microsoft.com/en-us/dotnet/api/system.string): Returns or sets the key of the default image shown when a [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md) is selected.

### ![](/files/-MTRl851gGvQXMvSEG1f)SelectedNode

[TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md): Returns or sets the tree node that is currently selected in the tree view control.

### ![](/files/-MTRl851gGvQXMvSEG1f)SelectedNodes

[TreeNode\[\]](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md): Returns or sets the tree nodes that are currently selected in the tree view control. Use this property when the SelectionMode is MultiSimple or MultiExtended.

### ![](/files/-MTRl851gGvQXMvSEG1f)SelectionMode

[SelectionMode](/api/v2.5/wisej.web/enumerations/wisej.web.selectionmode.md): Returns or sets the method in which items are selected in the [TreeView](/api/v2.5/wisej.web/lists-and-grids/treeview.md).

### ![](/files/-MTRl851gGvQXMvSEG1f)ShowNodeToolTips

[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean): Returns or sets a value indicating ToolTips are shown when the mouse pointer hovers over a [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md).

### ![](/files/-MTRl851gGvQXMvSEG1f)ShowPlusMinus

[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean): Returns or sets whether plus-sign (+) and minus-sign (-) buttons are displayed next to tree nodes that contain child tree nodes.

### ![](/files/-MTRl851gGvQXMvSEG1f)ShowRootLines

[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean): Returns or sets whether lines are drawn between the tree nodes that are at the root of the tree view.

### ![](/files/-MTRl851gGvQXMvSEG1f)Sorted

[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean): Returns or sets whether the tree nodes in the tree view are sorted.

### ![](/files/-MTRl851gGvQXMvSEG1f)StateImageList

[ImageList](/api/v2.5/wisej.web/content/imagelist.md): Returns or sets the image list that is used to indicate the state of the [TreeView](/api/v2.5/wisej.web/lists-and-grids/treeview.md) and its nodes.

### ![](/files/-MTRl851gGvQXMvSEG1f)Tools

[ComponentToolCollection](/api/v2.5/wisej.web/editors/wisej.web.componenttoolcollection.md): Returns the instance of [ComponentToolCollection](/api/v2.5/wisej.web/editors/wisej.web.componenttoolcollection.md) associated with this control.

### ![](/files/-MTRl851gGvQXMvSEG1f)TopNode

[TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md): Returns or sets the first fully-visible tree node in the tree view control.

### ![](/files/-MTRl851gGvQXMvSEG1f)TreeViewNodeSorter

[IComparer\<TreeNode>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.icomparer): Returns or sets the implementation of [IComparer](https://docs.microsoft.com/en-us/dotnet/api/system.collections.icomparer) to perform a custom sort of the [TreeView](/api/v2.5/wisej.web/lists-and-grids/treeview.md) nodes.

### ![](/files/-MTRl851gGvQXMvSEG1f)VirtualScroll

[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean): Enables or disables virtual scrolling for the [TreeView](/api/v2.5/wisej.web/lists-and-grids/treeview.md). When virtual scrolling is enabled, only the visible nodes are rendered in the browser allowing the [TreeView](/api/v2.5/wisej.web/lists-and-grids/treeview.md) to host virtually unlimited nodes without any performance loss.

When [VirtualScroll](#virtualscroll) is set to true, all the nodes must be of the same height, limiting the more flexible HTML rendering in the nodes available when [VirtualScroll](#virtualscroll) is off (default). Setting the property [PrefetchItems](#prefetchitems) to a value greater than 0 allows the virtual view to prefetch the specified number of items outside of the visible area to enable smoother scrolling.

## Methods

### ![](/files/-MTRl851gGvQXMvSEG1f)BeginUpdate()

This method has no effect on this control.

### ![](/files/-MTRl851gGvQXMvSEG1f)ClearSelected()

Unselects all nodes in the [TreeView](/api/v2.5/wisej.web/lists-and-grids/treeview.md).

### ![](/files/-MTRl851gGvQXMvSEG1f)CollapseAll()

Collapses all the tree nodes.

### ![](/files/-MTRl851gGvQXMvSEG1f)EndUpdate()

This method has no effect on this control.

### ![](/files/-MTRl851gGvQXMvSEG1f)ExpandAll()

Expands all the tree nodes.

### ![](/files/-MTRl851gGvQXMvSEG1f)GetNodeCount(includeSubTrees)

Retrieves the number of tree nodes, optionally including those in all subtrees, assigned to the tree view control.

| Parameter           | Type                                                                  | Description                                                                                                                                         |
| ------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| **includeSubTrees** | [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean) | true to count the [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md) items that the subtrees contain; otherwise, false. |

**Returns:** [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32). The number of tree nodes, optionally including those in all subtrees, assigned to the tree view control.

### ![](/files/-MTRl851gGvQXMvSEG1f)GetSelected(node)

Returns a value indicating whether the specified [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md) is selected.

| Parameter | Type                                                                           | Description                                                                                  |
| --------- | ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
| **node**  | [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md) | The [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md) to check. |

**Returns:** [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean). true if the specified [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md) is currently selected in the [TreeView](/api/v2.5/wisej.web/lists-and-grids/treeview.md); otherwise, false.

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentnullexception) The specified *node* is null.
* [ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception) The specified *node* is currently assigned to another [TreeView](/api/v2.5/wisej.web/lists-and-grids/treeview.md).

### ![](/files/-MTRl851gGvQXMvSEG1f)SetSelected(node, selected)

Selects or clears the selection for the specified [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md) in a [TreeView](/api/v2.5/wisej.web/lists-and-grids/treeview.md).

| Parameter    | Type                                                                           | Description                                                                                                                                  |
| ------------ | ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
| **node**     | [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md) | The [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md) to select.                                                |
| **selected** | [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)          | True to select the specified [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md), otherwise false to deselect it. |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentnullexception) The specified *node* is null.
* [ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception) The specified *node* is currently assigned to another [TreeView](/api/v2.5/wisej.web/lists-and-grids/treeview.md).
* [InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception) The [SelectionMode](#selectionmode) property is set to None.

### ![](/files/-MTRl851gGvQXMvSEG1f)Sort()

Sorts the items in [TreeView](/api/v2.5/wisej.web/lists-and-grids/treeview.md) control.

## Events

### ![](/files/-MTRl851gGvQXMvSEG1f)AfterCheck

[TreeViewEventHandler](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treevieweventhandler.md) Occurs after the tree node check box is checked.

### ![](/files/-MTRl851gGvQXMvSEG1f)AfterCollapse

[TreeViewEventHandler](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treevieweventhandler.md) Occurs after the tree node is collapsed.

### ![](/files/-MTRl851gGvQXMvSEG1f)AfterExpand

[TreeViewEventHandler](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treevieweventhandler.md) Occurs after the tree node is expanded.

### ![](/files/-MTRl851gGvQXMvSEG1f)AfterLabelEdit

[NodeLabelEditEventHandler](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.nodelabelediteventhandler.md) Occurs after the tree node label text is edited.

### ![](/files/-MTRl851gGvQXMvSEG1f)AfterSelect

[TreeViewEventHandler](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treevieweventhandler.md) Occurs after the tree node is selected.

### ![](/files/-MTRl851gGvQXMvSEG1f)BeforeCheck

[TreeViewCancelEventHandler](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treeviewcanceleventhandler.md) Occurs before the tree node check box is checked.

### ![](/files/-MTRl851gGvQXMvSEG1f)BeforeCollapse

[TreeViewCancelEventHandler](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treeviewcanceleventhandler.md) Occurs before the tree node is collapsed.

### ![](/files/-MTRl851gGvQXMvSEG1f)BeforeExpand

[TreeViewCancelEventHandler](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treeviewcanceleventhandler.md) Occurs before the tree node is expanded.

### ![](/files/-MTRl851gGvQXMvSEG1f)BeforeLabelEdit

[NodeLabelEditEventHandler](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.nodelabelediteventhandler.md) Occurs before the tree node label text is edited.

### ![](/files/-MTRl851gGvQXMvSEG1f)BeforeSelect

[TreeViewCancelEventHandler](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treeviewcanceleventhandler.md) Occurs before the tree node is selected.

### ![](/files/-MTRl851gGvQXMvSEG1f)ItemDrag

![](/files/-MUTv-x4we7VnevpwHiW)**Deprecated**: This event is deprecated. Use NodeDrag instead. [ItemDragEventHandler](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.itemdrageventhandler.md) Fired when the user begins dragging a node.

### ![](/files/-MTRl851gGvQXMvSEG1f)NodeDrag

[TreeViewNodeDragEventHandler](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treeviewnodedrageventhandler.md) Fired when the user begins dragging a node.

### ![](/files/-MTRl851gGvQXMvSEG1f)NodeMouseClick

[TreeNodeMouseClickEventHandler](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenodemouseclickeventhandler.md) Fired when the user clicks a [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md) with the mouse.

### ![](/files/-MTRl851gGvQXMvSEG1f)NodeMouseDoubleClick

[TreeNodeMouseClickEventHandler](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenodemouseclickeventhandler.md) Fired when the user double-clicks a [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md) with the mouse.

### ![](/files/-MTRl851gGvQXMvSEG1f)NodeMouseHover

[TreeNodeMouseHoverEventHandler](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenodemousehovereventhandler.md) Fired when the mouse hovers over a [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md).

### ![](/files/-MTRl851gGvQXMvSEG1f)NodeMouseLeave

[TreeNodeMouseHoverEventHandler](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenodemousehovereventhandler.md) Fired when the mouse leaves the [TreeNode](/api/v2.5/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md).

### ![](/files/-MTRl851gGvQXMvSEG1f)ToolClick

[ToolClickEventHandler](/api/v2.5/wisej.web/lists-and-grids/treeview.md) Fired when a [ComponentTool](/api/v2.5/wisej.web/editors/wisej.web.componenttool.md) is clicked.

## Implements

| Name                                                                                   | Description                                                                                                                |
| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| [IBindableComponent](/api/v2.5/wisej.web/data-binding/wisej.web.ibindablecomponent.md) | Bindable components implement this interface.                                                                              |
| [IWisejComponent](/api/v2.5/wisej.core/interfaces/wisej.core.iwisejcomponent.md)       | All wisej components implement this interface.                                                                             |
| [IWisejControl](/api/v2.5/wisej.core/interfaces/wisej.core.iwisejcontrol.md)           | All wisej controls derived from the [Control](/api/v2.5/wisej.web/general/control.md) class must implement this interface. |
| [IWisejSerializable](/api/v2.5/wisej.core/interfaces/wisej.core.iwisejserializable.md) | Allows an object to serialize itself.                                                                                      |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/treeview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
