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.

TreeViewEventArgs.Action Property


Gets the type of action that raised the event.

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

public TreeViewAction Action { get; }

Property Value

Type: System.Windows.Forms.TreeViewAction

The type of TreeViewAction that raised the event.

The following example illustrates a customized TreeView. By inheriting the TreeView class, this custom version has all the functionality of a normal TreeView. Changing various property values in the constructor provides a unique appearance. Because the ShowPlusMinus property is set to false, the customized control also overrides the OnAfterSelect method so nodes can be expanded and collapsed when they are clicked.

A control that is customized in this way can be used throughout an organization, making it easy to provide a consistent interface without requiring the control properties to be specified in each individual project.

public class CustomizedTreeView : TreeView
    public CustomizedTreeView()
        // Customize the TreeView control by setting various properties.
        BackColor = System.Drawing.Color.CadetBlue;
        FullRowSelect = true;
        HotTracking = true;
        Indent = 34;
        ShowPlusMinus = false;

        // The ShowLines property must be false for the FullRowSelect 
        // property to work.
        ShowLines = false;

    protected override void OnAfterSelect(TreeViewEventArgs e)
        // Confirm that the user initiated the selection.
        // This prevents the first node from expanding when it is
        // automatically selected during the initialization of 
        // the TreeView control.
        if (e.Action != TreeViewAction.Unknown)
            if (e.Node.IsExpanded) 

        // Remove the selection. This allows the same node to be
        // clicked twice in succession to toggle the expansion state.
        SelectedNode = null;


.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft