TreeNode
Namespace: Wisej.Web
Assembly: Wisej.Framework (4.1.0.0)
Represents a node of a TreeView.
- C#
- VB.NET
public class TreeNode : Component, ICloneable, IHasPropertyStore, IImage
Public Class TreeNode
Inherits Component
Implements ICloneable, IHasPropertyStore, IImage
Constructors
TreeNode()
Initializes a new instance of the TreeNode class.
TreeNode(text)
Initializes a new instance of the TreeNode class with the specified label text.
TreeNode(text, children)
Initializes a new instance of the TreeNode class with the specified label text and child tree nodes.
| Name | Type | Description |
|---|---|---|
| text | String | The label Text of the new tree node. |
| children | TreeNode[] | An array of child TreeNode objects. |
TreeNode(text, imageIndex, selectedImageIndex)
Initializes a new instance of the TreeNode class with the specified label text and images to display when the tree node is in a selected and unselected state.
| Name | Type | Description |
|---|---|---|
| text | String | The label Text of the new tree node. |
| imageIndex | Int32 | The index value of Image to display when the tree node is unselected. |
| selectedImageIndex | Int32 | The index value of Image to display when the tree node is selected. |
TreeNode(text, imageIndex, selectedImageIndex, children)
Initializes a new instance of the TreeNode class with the specified label text, child tree nodes, and images to display when the tree node is in a selected and unselected state.
| Name | Type | Description |
|---|---|---|
| text | String | The label Text of the new tree node. |
| imageIndex | Int32 | The index value of Image to display when the tree node is unselected. |
| selectedImageIndex | Int32 | The index value of Image to display when the tree node is selected. |
| children | TreeNode[] | An array of child TreeNode objects. |
Properties
AllowHtml
Boolean: Returns or sets a value indicating that the tree node can display HTML in the Text property. (Default: False)
BackColor
Color: Returns or sets the background color of the tree node.
Value: The background Color of the tree node. The default is Empty.
CheckBox
Nullable<Boolean>: Returns or sets whether a checkbox is displayed next to the tree node. (Default: null)
Value: true if a check box is displayed next to the tree node; otherwise null to inherit from the parent tree view, or false to hide the checkbox. The default is null.
Checked
Boolean: Returns or sets whether the tree node is in a checked state. (Default: False)
Value: true if the tree node is in a checked state; otherwise, false.
CheckState
CheckState: Returns or sets the checked state of the tree node. (Default: Unchecked)
Value: One of the CheckState enumeration values. The default value is Unchecked.
ContextMenu
ContextMenu: Returns the shortcut menu that is associated with this tree node. (Default: null)
Value: The ContextMenu that is associated with the tree node.
Enabled
Boolean: Returns or sets whether the tree node is in enabled. (Default: True)
Value: true if the tree node is enabled; otherwise, false.
Events
EventHandlerList: Returns the list of event handlers that are attached to this Component.
Value: An EventHandlerList that provides the delegates for this component.
FirstNode
TreeNode: Returns the first child tree node in the tree node collection.
Value: The first child TreeNode in the Nodes collection.
ForeColor
Color: Returns or sets the foreground color of the tree node.
Value: The foreground Color of the tree node.
FullPath
String: Returns the path from the root tree node to the current tree node.
Value: The path from the root tree node to the current tree node.
Handle
IntPtr: Returns a value representing the handle for the TreeNode.
Value: The handle of the TreeNode.
HideNodeImage
Nullable<Boolean>: Returns or sets a valid indicating whether the node image next to the tree node is hidden. (Default: null)
Value: true if the image is hidden; otherwise null to inherit from the parent tree view, or false to show the image. The default is null.
ImageIndex
Int32: Returns or sets the image list index value of the image displayed when the tree node is in the unselected state. (Default: -1)
Value: A zero-based index value that represents the image position in the assigned ImageList.
Throws:
- ArgumentOutOfRangeException The specified index is less than -1.
ImageKey
String: Returns or sets the key for the image associated with this tree node when the node is in an unselected state. (Default: "")
Value: The key for the image associated with this tree node when the node is in an unselected state.
ImageList
ImageList: Returns the ImageList that contains the images displayed in the TreeNode.
Value: The ImageList used by the TreeView control that owns this TreeNode.
Index
Int32: Returns the position of the tree node in the tree node collection.
Value: A zero-based index value that represents the position of the tree node in the Nodes collection.
IsEditing
Boolean: Returns a value indicating whether the tree node is in an editable state.
Value: true if the tree node is in editable state; otherwise, false.
IsEnabled
Boolean: Returns or sets whether the tree node is enabled.
Value: true if the tree node is enabled; the default is true.
IsExpanded
Boolean: Returns a value indicating whether the tree node is in the expanded state.
Value: true if the tree node is in the expanded state; otherwise, false.
IsParent
Boolean: Returns or sets whether the tree node is a parent node and can be expanded.
Setting this property to true when the node doesn't have any children, will cause the node to expand anyway and request the child nodes from the server.
IsSelected
Boolean: Returns a value indicating whether the tree node is in the selected state.
Value: true if the tree node is in the selected state; otherwise, false.
LastNode
TreeNode: Returns the last child tree node.
Value: A TreeNode that represents the last child tree node.
LazyLoading
Boolean: Returns or sets whether child nodes are sent to the client the first time this node is expanded. (Default: False)
This option sends less data to the client and speeds up the creation of tree nodes with many child nodes. It can be used in conjunction with the property ShowLoader.
Level
Int32: Returns the zero-based depth of the tree node in the TreeView control.
Value: The zero-based depth of the tree node in the TreeView control.
Name
String: Returns or sets the name of the tree node.
Value: A String that represents the name of the tree node.
NextNode
TreeNode: Returns the next sibling tree node.
Value: A TreeNode that represents the next sibling tree node.
NextVisibleNode
TreeNode: Returns the next visible tree node.
Value: A TreeNode that represents the next visible tree node.
NodeCount 3.1+
Int32: Returns the number of child nodes without forcing the creation of the collection.
NodeFont
Font: Returns or sets the font that is used to display the text on the tree node label.
Value: The Font that is used to display the text on the tree node label.
Nodes
TreeNodeCollection: Returns the collection of tree nodes assigned to the current tree node.
Value: A TreeNodeCollection that represents the tree nodes assigned to the current tree node.
OpenedImageIndex
Int32: Returns or sets the index of the image that is used when the tree node is expanded. (Default: -1)
Value: The index of the image that is used to indicate the state of the TreeNode.
Throws:
- ArgumentOutOfRangeException The specified index is less than -1.
OpenedImageKey
String: Returns or sets the key of the image that is used when the tree node is expanded. (Default: "")
Value: The key of the image that is used to indicate the state of the TreeNode.
Parent
TreeNode: Returns the parent tree node of the current tree node.
Value: A TreeNode that represents the parent of the current tree node.
PrevNode
TreeNode: Returns the previous sibling tree node.
Value: A TreeNode that represents the previous sibling tree node.
PrevVisibleNode
TreeNode: Returns the previous visible tree node.
Value: A TreeNode that represents the previous visible tree node.
SelectedImageIndex
Int32: Returns or sets the image list index value of the image that is displayed when the tree node is in the selected state. (Default: -1)
Value: A zero-based index value that represents the image position in an ImageList.
Throws:
- ArgumentOutOfRangeException The specified index is less than -1.
SelectedImageKey
String: Returns or sets the key of the image displayed in the tree node when it is in a selected state. (Default: "")
Value: The key of the image displayed when the tree node is in a selected state.
ShowLoader
Boolean: Returns or sets whether the tree node shows the node-loader image when it is expanding but it doesn't have any child nodes. (Default: False)
StateImageIndex
Int32: Returns or sets the index of the image that is used to indicate the state of the tree node when the parent TreeView has its CheckBoxes property set to false. (Default: -1)
Value: The index of the image that is used to indicate the state of the TreeNode.
Throws:
- ArgumentOutOfRangeException The specified index is less than -1.
StateImageKey
String: Returns or sets the key of the image that is used to indicate the state of the tree node when the parent TreeView has its CheckBoxes property set to false. (Default: "")
Value: The key of the image that is used to indicate the state of the TreeNode.
Tag
Object: Returns or sets the object that contains data about the tree node. (Default: null)
Value: An Object that contains data about the tree node. The default is null.
Text
String: Returns or sets the text displayed in the label of the tree node. (Default: "")
Value: The text displayed in the label of the tree node.
When AllowHtml is set to true, the text can contain HTML content. If the text contains new lines (CRLF) but doesn't contain HTML elements (at least one "<") all CRLF are automatically substituted with "<br/>".
ToolTipText
String: Returns or sets the text that appears when the mouse pointer hovers over a tree node. (Default: "")
Value: Gets the text that appears when the mouse pointer hovers over a TreeNode.
TreeView
TreeView: Returns the parent TreeView.
Value: A TreeView that contains this tree node.
Visible
Boolean: Returns or sets whether the tree node is visible. (Default: True)
Value: true if the TreeNode item is rendered in the parent TreeView control. The default is true.
Methods
AddHandler(key, handler)
Adds a delegate to the handler list for the specified event key.
| Parameter | Type | Description |
|---|---|---|
| key | Object | The key identifier for the event. |
| handler | Delegate | The handler to add to the list. |
BeginEdit()
Initiates the editing of the tree node label.
Throws:
- InvalidOperationException LabelEdit is set to false.
Clone()
Copies the tree node and the entire subtree rooted at this tree node.
Returns: Object. The Object that represents the cloned TreeNode.
Collapse()
Collapses the tree node.
Collapse(ignoreChildren)
Collapses the tree node and optionally collapses its children.
| Parameter | Type | Description |
|---|---|---|
| ignoreChildren | Boolean | true to leave the child nodes in their current state; false to collapse the child nodes. |
CollapseAll()
Collapses the tree node and all its children.
Dispose(disposing)
Disposes the tree node.
| Parameter | Type | Description |
|---|---|---|
| disposing | Boolean | true when this method is called by the application rather than a finalizer. |
EndEdit(cancel)
Cancels the editing of the tree node label.
| Parameter | Type | Description |
|---|---|---|
| cancel | Boolean | True to discard the edited value. |
EnsureVisible()
Ensures that the tree node is visible, expanding tree nodes and scrolling the tree view control as necessary.
Expand()
Expands the tree node.
ExpandAll()
Expands all the child tree nodes.
FromHandle(tree, handle)
Returns the TreeNode with the specified handle and assigned to the specified TreeView control.
| Parameter | Type | Description |
|---|---|---|
| tree | TreeView | The TreeView that contains the TreeNode. |
| handle | IntPtr | The handle of the TreeNode. |
Returns: TreeNode. The TreeNode assigned to the TreeView with the specified handle.
GetNodeCount(includeSubTrees)
Returns the number of child tree nodes.
| Parameter | Type | Description |
|---|---|---|
| includeSubTrees | Boolean | true if the resulting count includes all tree nodes indirectly rooted at this tree node; otherwise, false. |
Returns: Int32. The number of child tree nodes assigned to the Nodes collection.
OnAddReferences(items)
Returns a collection of referenced components or collection of components.
| Parameter | Type | Description |
|---|---|---|
| items | IList |
OnAfterCheck(e)
Fires the AfterCheck event.
| Parameter | Type | Description |
|---|---|---|
| e | TreeViewEventArgs | A TreeViewEventArgs that contains the event data. |
OnAfterCollapse(e)
Fires the AfterCollapse event.
| Parameter | Type | Description |
|---|---|---|
| e | TreeViewEventArgs | A TreeViewEventArgs that contains the event data. |
OnAfterExpand(e)
Fires the AfterExpand event.
| Parameter | Type | Description |
|---|---|---|
| e | TreeViewEventArgs | A TreeViewEventArgs that contains the event data. |
OnAfterLabelEdit(e)
Fires the AfterLabelEdit event.
| Parameter | Type | Description |
|---|---|---|
| e | NodeLabelEditEventArgs | A NodeLabelEditEventArgs that contains the event data. |
OnAfterSelect(e)
Fires the AfterSelect event.
| Parameter | Type | Description |
|---|---|---|
| e | TreeViewEventArgs | A TreeViewEventArgs that contains the event data. |
OnBeforeCheck(e)
Fires the BeforeCheck event.
| Parameter | Type | Description |
|---|---|---|
| e | TreeViewCancelEventArgs | A TreeViewCancelEventArgs that contains the event data. |
OnBeforeCollapse(e)
Fires the BeforeCollapse event.
| Parameter | Type | Description |
|---|---|---|
| e | TreeViewCancelEventArgs | A TreeViewCancelEventArgs that contains the event data. |
OnBeforeExpand(e)
Fires the BeforeExpand event.
| Parameter | Type | Description |
|---|---|---|
| e | TreeViewCancelEventArgs | A TreeViewCancelEventArgs that contains the event data. |
OnBeforeLabelEdit(e)
Fires the BeforeLabelEdit event.
| Parameter | Type | Description |
|---|---|---|
| e | NodeLabelEditEventArgs | A NodeLabelEditEventArgs that contains the event data. |
OnBeforeSelect(e)
Fires the BeforeSelect event.
| Parameter | Type | Description |
|---|---|---|
| e | TreeViewCancelEventArgs | A TreeViewCancelEventArgs that contains the event data. |
OnItemDrag(e)
Deprecated: This method is deprecated. Use OnNodeDrag instead.
Fires the ItemDrag event.
| Parameter | Type | Description |
|---|---|---|
| e | ItemDragEventArgs | An ItemDragEventArgs that contains the event data. |
OnNodeDrag(e)
Fires the NodeDrag event.
| Parameter | Type | Description |
|---|---|---|
| e | TreeViewNodeDragEventArgs | An TreeViewNodeDragEventArgs that contains the event data. |
OnNodeMouseClick(e)
Fires the NodeMouseClick event.
| Parameter | Type | Description |
|---|---|---|
| e | TreeNodeMouseClickEventArgs | A TreeNodeMouseClickEventArgs that contains the event data. |
OnNodeMouseDoubleClick(e)
Fires the NodeMouseDoubleClick event.
| Parameter | Type | Description |
|---|---|---|
| e | TreeNodeMouseClickEventArgs | A TreeNodeMouseClickEventArgs that contains the event data. |
OnNodeMouseHover(e)
Fires the NodeMouseHover event.
| Parameter | Type | Description |
|---|---|---|
| e | TreeNodeMouseHoverEventArgs | The TreeNodeMouseHoverEventArgs that contains the event data. |
OnNodeMouseLeave(e)
Fires the NodeMouseLeave event.
| Parameter | Type | Description |
|---|---|---|
| e | TreeNodeMouseHoverEventArgs | The TreeNodeMouseHoverEventArgs that contains the event data. |
OnWebRender(config)
Renders the client component.
| Parameter | Type | Description |
|---|---|---|
| config | Object | Dynamic configuration object. |
Remove()
Removes the current tree node from the tree view control.
RemoveHandler(key, handler)
Removes a delegate from the handler list for the specified event key.
| Parameter | Type | Description |
|---|---|---|
| key | Object | The key identifier for the event. |
| handler | Delegate | The handler to add to the list. |
Toggle()
Toggles the tree node to either the expanded or collapsed state.
Update()
Updates the component on the client. Overridden to repaint the tree view in design mode.
Events
AfterCheck
TreeViewEventHandler Occurs after the tree node check box is checked.
AfterCollapse
TreeViewEventHandler Occurs after the tree node is collapsed.
AfterExpand
TreeViewEventHandler Occurs after the tree node is expanded.
AfterLabelEdit
NodeLabelEditEventHandler Occurs after the tree node label text is edited.
AfterSelect
TreeViewEventHandler Occurs after the tree node is selected.
BeforeCheck
TreeViewCancelEventHandler Occurs before the tree node check box is checked.
BeforeCollapse
TreeViewCancelEventHandler Occurs before the tree node is collapsed.
BeforeExpand
TreeViewCancelEventHandler Occurs before the tree node is expanded.
BeforeLabelEdit
NodeLabelEditEventHandler Occurs before the tree node label text is edited.
BeforeSelect
TreeViewCancelEventHandler Occurs before the tree node is selected.
ItemDrag
Deprecated: This event is deprecated. Use NodeDrag instead.
ItemDragEventHandler Fired when the user begins dragging a TreeNode.
NodeDrag
TreeViewNodeDragEventHandler Fired when the user begins dragging a TreeNode.
NodeMouseClick
TreeNodeMouseClickEventHandler Fired when the user clicks a TreeNode with the mouse.
NodeMouseDoubleClick
TreeNodeMouseClickEventHandler Fired when the user double-clicks a TreeNode with the mouse.
NodeMouseHover
TreeNodeMouseHoverEventHandler Fired when the mouse hovers over a TreeNode.
NodeMouseLeave
TreeNodeMouseHoverEventHandler Fired when the mouse leaves the TreeNode.
Implements
| Name | Description |
|---|---|
| IUserData | Provides access to the UserData and Tag properties associated to the component implementing this interface. |
| IImage | Provides access to common image properties across the controls that implement this interface. |
| IWisejComponent | All wisej components implement this interface. |
| IWisejSerializable | Allows an object to serialize itself. |