Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

TreeView.AfterSelect Event

 

Occurs after the tree node is selected.

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

public event TreeViewEventHandler AfterSelect

This event does not occur when the node is unselected. To detect whether the selection was cleared, you can test the TreeNode.IsSelected property.

For more information about handling events, see Handling and Raising Events.

The following code example demonstrates how to use the TreeViewAction enumeration. To run this example, paste the following code in a form that contains a TreeView control named TreeView1. This example requires that TreeView1 is populated with items and the AfterSelect event is connected to the event handler defined in the sample.

// Handle the After_Select event.
private void TreeView1_AfterSelect(System.Object sender, 
	System.Windows.Forms.TreeViewEventArgs e)
{

	// Vary the response depending on which TreeViewAction
	// triggered the event. 
	switch((e.Action))
	{
		case TreeViewAction.ByKeyboard:
			MessageBox.Show("You like the keyboard!");
			break;
		case TreeViewAction.ByMouse:
			MessageBox.Show("You like the mouse!");
			break;
	}
}

.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft