TreeView Web Server Control Events
The TreeView Web server control provides several events that you can program. This allows you to run your custom routines whenever an event occurs.
TreeView control events are raised only when a user interacts with the control by doing such things as selecting, expanding, or collapsing a node. They are not raised if the select, expand, or collapse methods are called programmatically. For example, if you call the Expand method, no event will be raised.
The following table describes the events that are supported by the TreeView control.
|
Event |
Description |
|---|---|
|
Occurs when a check box of the TreeView control changes state between posts to the server. Occurs once for every TreeNode object that changes. |
|
|
Occurs when a node is selected in the TreeView control. |
|
|
Occurs when a node is expanded in the TreeView control. |
|
|
Occurs when a node is collapsed in the TreeView control. |
|
|
Occurs when a node, with its PopulateOnDemand property set to true, is expanded in the TreeView control. |
|
|
Occurs when a data item is bound to a node in the TreeView control. |
The following code example demonstrates handling the SelectedNodeChanged event and accessing the SelectedNode property that raised the event. It sets the text of MyLabel to be the ToolTip property text of the SelectedNode.
The following code example demonstrates handling the TreeNodeCollapsed event and the TreeNodeExpanded event and then accessing the TreeNode object that was collapsed or expanded.
The following code example demonstrates handling the TreeNodePopulate event and then programmatically adding a new TreeNode object to the ChildNodes collection of the node that raised the event.