Occurs before the tree node is collapsed.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The following code example demonstrates how to change the collapse state of a TreeView so that all the checked nodes are visible. First, all the nodes are expanded, and a handler is added for the event. Next, all the nodes are collapsed. The event handler determines whether a given node has child nodes that are checked. If a node has checked children, the collapse is canceled for that node. In order to allow standard node collapse when the minus sign next to a node is clicked, the event handler is then removed.
This behavior can also be implemented by handling the BeforeExpand event, as illustrated in the example for that topic.
For the complete example, see the TreeView constructor reference topic.
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.