TreeViewCancelEventHandler Delegate

 

Represents the method that will handle the BeforeCheck, BeforeCollapse, BeforeExpand, or BeforeSelect event of a TreeView.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

type TreeViewCancelEventHandler = 
    delegate of 
        sender:Object *
        e:TreeViewCancelEventArgs -> unit

Parameters

sender
Type: System.Object

The source of the event.

e
Type: System.Windows.Forms.TreeViewCancelEventArgs

A TreeViewCancelEventArgs that contains the event data.

When you create a TreeViewCancelEventArgs delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, 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.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: