TreeViewCancelEventArgs Class
Provides data for the BeforeCheck, BeforeCollapse, BeforeExpand, and BeforeSelect events of a TreeView control.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
System.EventArgs
System.ComponentModel.CancelEventArgs
System.Windows.Forms.TreeViewCancelEventArgs
| Name | Description | |
|---|---|---|
![]() | TreeViewCancelEventArgs(TreeNode, Boolean, TreeViewAction) | Initializes a new instance of the TreeViewCancelEventArgs class with the specified tree node, a value specifying whether the event is to be canceled, and the type of tree view action that raised the event. |
| Name | Description | |
|---|---|---|
![]() | Action | Gets the type of TreeView action that raised the event. |
![]() | Cancel | Gets or sets a value indicating whether the event should be canceled.(Inherited from CancelEventArgs.) |
![]() | Node | Gets the tree node to be checked, expanded, collapsed, or selected. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Finalize() | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.) |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | MemberwiseClone() | |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
For more information about handling events, see Handling and Raising Events.
The following example demonstrates how to change the collapse state of a TreeView so that all the checked nodes are visible. First, all the nodes are collapsed, and a handler is added to the TreeView.BeforeExpand event. Next, all the nodes are expanded. The TreeView.BeforeExpand event handler determines whether a given node has child nodes that are checked. If a node does not have checked children, the expansion is canceled for that node. In order to allow normal node expansion when the plus sign next to a node is clicked, the TreeView.BeforeExpand event handler is then removed.
This behavior can also be implemented by handling the TreeView.BeforeCollapse event, as illustrated in the example for that topic.
For the complete example, see the TreeView.CheckBoxes reference topic.
Available since 1.1
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


