TreeViewEventArgs TreeViewEventArgs TreeViewEventArgs TreeViewEventArgs Class

Definición

Proporciona datos de los eventos AfterCheck, AfterCollapse, AfterExpand o AfterSelect de un control TreeView.Provides data for the AfterCheck, AfterCollapse, AfterExpand, or AfterSelect events of a TreeView control.

public ref class TreeViewEventArgs : EventArgs
public class TreeViewEventArgs : EventArgs
type TreeViewEventArgs = class
    inherit EventArgs
Public Class TreeViewEventArgs
Inherits EventArgs
Herencia
TreeViewEventArgsTreeViewEventArgsTreeViewEventArgsTreeViewEventArgs

Ejemplos

El ejemplo siguiente muestra una personalizada TreeView.The following example illustrates a customized TreeView. Al heredar el TreeView (clase), esta versión personalizada tiene toda la funcionalidad de un mapa normal TreeView.By inheriting the TreeView class, this custom version has all the functionality of a normal TreeView. Cambiar varios valores de propiedad en el constructor, proporciona una apariencia única.Changing various property values in the constructor provides a unique appearance. Dado que el ShowPlusMinus propiedad está establecida en false, el control personalizado también reemplaza el OnAfterSelect método por lo que pueden expandir y contraer cuando se hace clic en los nodos.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.

Un control personalizado de esta manera puede usarse en toda la organización, facilitando el proceso proporcionar una interfaz coherente sin necesidad de las propiedades del control que se especifique en cada proyecto individual.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 ref class CustomizedTreeView: public 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:
   virtual void OnAfterSelect( TreeViewEventArgs^ e ) override
   {
      // 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 )
         {
            e->Node->Collapse();
         }
         else
         {
            e->Node->Expand();
         }
      }

      
      // Remove the selection. This allows the same node to be
      // clicked twice in succession to toggle the expansion state.
      SelectedNode = nullptr;
   }
};
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) 
            {
                e.Node.Collapse();
            }
            else 
            {
                e.Node.Expand();
            }
        }

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

}
Public Class CustomizedTreeView
    Inherits TreeView

    Public Sub New()
        ' 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
    End Sub 'New


    Protected Overrides Sub OnAfterSelect(ByVal e As TreeViewEventArgs)
        ' 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 Then
            If e.Node.IsExpanded Then
                e.Node.Collapse()
            Else
                e.Node.Expand()
            End If
        End If

        ' Remove the selection. This allows the same node to be
        ' clicked twice in succession to toggle the expansion state.
        SelectedNode = Nothing
    End Sub 'OnAfterSelect

End Class 'CustomizedTreeView 

Comentarios

Para obtener más información sobre el manejo de eventos, consulte controlar y provocar eventos.For more information about handling events, see Handling and Raising Events.

Constructores

TreeViewEventArgs(TreeNode) TreeViewEventArgs(TreeNode) TreeViewEventArgs(TreeNode) TreeViewEventArgs(TreeNode)

Inicializa una nueva instancia de la clase TreeViewEventArgs correspondiente al nodo de árbol especificado.Initializes a new instance of the TreeViewEventArgs class for the specified tree node.

TreeViewEventArgs(TreeNode, TreeViewAction) TreeViewEventArgs(TreeNode, TreeViewAction) TreeViewEventArgs(TreeNode, TreeViewAction) TreeViewEventArgs(TreeNode, TreeViewAction)

Inicializa una nueva instancia de la clase TreeViewEventArgs correspondiente al nodo de árbol especificado y con el tipo de acción especificado que ha provocado el evento.Initializes a new instance of the TreeViewEventArgs class for the specified tree node and with the specified type of action that raised the event.

Propiedades

Action Action Action Action

Obtiene el tipo de acción que ha generado el evento.Gets the type of action that raised the event.

Node Node Node Node

Obtiene el nodo de árbol que se ha comprobado, expandido, contraído o seleccionado.Gets the tree node that has been checked, expanded, collapsed, or selected.

Métodos

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina si el objeto especificado es igual al objeto actual.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Sirve como la función hash predeterminada.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del objeto Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Inherited from Object)

Se aplica a

Consulte también: