TreeViewDrawMode TreeViewDrawMode TreeViewDrawMode TreeViewDrawMode Enum

Definición

Define las constantes que representan cómo se puede dibujar un control TreeView.Defines constants that represent the ways a TreeView can be drawn.

public enum class TreeViewDrawMode
public enum TreeViewDrawMode
type TreeViewDrawMode = 
Public Enum TreeViewDrawMode
Herencia
TreeViewDrawModeTreeViewDrawModeTreeViewDrawModeTreeViewDrawMode

Campos

Normal Normal Normal Normal 0

El sistema operativo ha dibujado el control TreeView.The TreeView is drawn by the operating system.

OwnerDrawAll OwnerDrawAll OwnerDrawAll OwnerDrawAll 2

Se dibujan manualmente todos los elementos de un nodo TreeView, incluso los iconos, casillas, los signos de más y menos, y las líneas que conectan los nodos.All elements of a TreeView node are drawn manually, including icons, checkboxes, plus and minus signs, and lines connecting the nodes.

OwnerDrawText OwnerDrawText OwnerDrawText OwnerDrawText 1

Se dibuja manualmente la parte de la etiqueta de los nodos TreeView.The label portion of the TreeView nodes are drawn manually. El sistema operativo dibuja otros elementos de nodo, incluyendo los iconos, casillas, los signos de más y menos y las líneas que conectan los nodos.Other node elements are drawn by the operating system, including icons, checkboxes, plus and minus signs, and lines connecting the nodes.

Ejemplos

En el ejemplo de código siguiente se muestra cómo personalizar un TreeView controlar mediante su funcionalidad dibujado por el propietario.The following code example demonstrates how to customize a TreeView control using its owner-draw capability. El TreeView control en el ejemplo muestra etiquetas de nodo opcional junto con las etiquetas de nodo estándar.The TreeView control in the example displays optional node tags alongside the standard node labels. Las etiquetas de nodo se especifican utilizando el TreeNode.Tag propiedad.Node tags are specified using the TreeNode.Tag property. El TreeView control también usa los colores personalizados, incluido un color de resaltado personalizados.The TreeView control also uses custom colors, including a custom highlight color.

Puede personalizar la mayoría de los TreeView colores estableciendo las propiedades de color, pero el color de resaltado de la selección no está disponible como una propiedad.You can customize most of the TreeView colors by setting color properties, but the selection highlight color is not available as a property. Además, el rectángulo de resaltado de selección predeterminado se extiende sólo alrededor de una etiqueta de nodo.Additionally, the default selection highlight rectangle extends only around a node label. Dibujo del propietario debe utilizarse para dibujar las etiquetas de nodo y para dibujar un rectángulo de resaltado personalizados lo suficientemente grande como para incluir una etiqueta de nodo.Owner drawing must be used to draw the node tags and to draw a customized highlight rectangle large enough to include a node tag.

Para obtener un ejemplo completo, vea el TreeView.DrawNode tema de referencia.For the complete example, see the TreeView.DrawNode reference topic.

TreeViewOwnerDraw()
{
   tagFont = gcnew System::Drawing::Font( "Helvetica",8,FontStyle::Bold );

   // Create and initialize the TreeView control.
   myTreeView = gcnew TreeView;
   myTreeView->Dock = DockStyle::Fill;
   myTreeView->BackColor = Color::Tan;
   myTreeView->CheckBoxes = true;
   
   // Add nodes to the TreeView control.
   TreeNode^ node;
   for ( int x = 1; x < 4; ++x )
   {
      // Add a root node to the TreeView control.
      node = myTreeView->Nodes->Add( String::Format( "Task {0}", x ) );
      for ( int y = 1; y < 4; ++y )
      {
         // Add a child node to the root node.
         node->Nodes->Add( String::Format( "Subtask {0}", y ) );
      }
   }
   myTreeView->ExpandAll();
   
   // Add tags containing alert messages to a few nodes 
   // and set the node background color to highlight them.
   myTreeView->Nodes[ 1 ]->Nodes[ 0 ]->Tag = "urgent!";
   myTreeView->Nodes[ 1 ]->Nodes[ 0 ]->BackColor = Color::Yellow;
   myTreeView->SelectedNode = myTreeView->Nodes[ 1 ]->Nodes[ 0 ];
   myTreeView->Nodes[ 2 ]->Nodes[ 1 ]->Tag = "urgent!";
   myTreeView->Nodes[ 2 ]->Nodes[ 1 ]->BackColor = Color::Yellow;
   
   // Configure the TreeView control for owner-draw and add
   // a handler for the DrawNode event.
   myTreeView->DrawMode = TreeViewDrawMode::OwnerDrawText;
   myTreeView->DrawNode += gcnew DrawTreeNodeEventHandler( this, &TreeViewOwnerDraw::myTreeView_DrawNode );
   
   // Add a handler for the MouseDown event so that a node can be 
   // selected by clicking the tag text as well as the node text.
   myTreeView->MouseDown += gcnew MouseEventHandler( this, &TreeViewOwnerDraw::myTreeView_MouseDown );
   
   // Initialize the form and add the TreeView control to it.
   this->ClientSize = System::Drawing::Size( 292, 273 );
   this->Controls->Add( myTreeView );
}
public TreeViewOwnerDraw()
{
    // Create and initialize the TreeView control.
    myTreeView = new TreeView();
    myTreeView.Dock = DockStyle.Fill;
    myTreeView.BackColor = Color.Tan;
    myTreeView.CheckBoxes = true;

    // Add nodes to the TreeView control.
    TreeNode node;
    for (int x = 1; x < 4; ++x)
    {
        // Add a root node to the TreeView control.
        node = myTreeView.Nodes.Add(String.Format("Task {0}", x));
        for (int y = 1; y < 4; ++y)
        {
            // Add a child node to the root node.
            node.Nodes.Add(String.Format("Subtask {0}", y));
        }
    }
    myTreeView.ExpandAll();

    // Add tags containing alert messages to a few nodes 
    // and set the node background color to highlight them.
    myTreeView.Nodes[1].Nodes[0].Tag = "urgent!";
    myTreeView.Nodes[1].Nodes[0].BackColor = Color.Yellow;
    myTreeView.SelectedNode = myTreeView.Nodes[1].Nodes[0];
    myTreeView.Nodes[2].Nodes[1].Tag = "urgent!";
    myTreeView.Nodes[2].Nodes[1].BackColor = Color.Yellow;

    // Configure the TreeView control for owner-draw and add
    // a handler for the DrawNode event.
    myTreeView.DrawMode = TreeViewDrawMode.OwnerDrawText;
    myTreeView.DrawNode += 
        new DrawTreeNodeEventHandler(myTreeView_DrawNode);

    // Add a handler for the MouseDown event so that a node can be 
    // selected by clicking the tag text as well as the node text.
    myTreeView.MouseDown += new MouseEventHandler(myTreeView_MouseDown);

    // Initialize the form and add the TreeView control to it.
    this.ClientSize = new Size(292, 273);
    this.Controls.Add(myTreeView);
}
Public Sub New()

    ' Create and initialize the TreeView control.
    myTreeView = New TreeView()
    myTreeView.Dock = DockStyle.Fill
    myTreeView.BackColor = Color.Tan
    myTreeView.CheckBoxes = True
    
    ' Add nodes to the TreeView control.
    Dim node As TreeNode
    Dim x As Integer
    For x = 1 To 3

        ' Add a root node to the TreeView control.
        node = myTreeView.Nodes.Add(String.Format("Task {0}", x))
        Dim y As Integer
        For y = 1 To 3 

            ' Add a child node to the root node.
            node.Nodes.Add(String.Format("Subtask {0}", y))
        Next y
    Next x
    myTreeView.ExpandAll()
    
    ' Add tags containing alert messages to a few nodes 
    ' and set the node background color to highlight them.
    myTreeView.Nodes(1).Nodes(0).Tag = "urgent!"
    myTreeView.Nodes(1).Nodes(0).BackColor = Color.Yellow
    myTreeView.SelectedNode = myTreeView.Nodes(1).Nodes(0)
    myTreeView.Nodes(2).Nodes(1).Tag = "urgent!"
    myTreeView.Nodes(2).Nodes(1).BackColor = Color.Yellow
    
    ' Configure the TreeView control for owner-draw.
    myTreeView.DrawMode = TreeViewDrawMode.OwnerDrawText

    ' Add a handler for the MouseDown event so that a node can be 
    ' selected by clicking the tag text as well as the node text.
    AddHandler myTreeView.MouseDown, AddressOf myTreeView_MouseDown
    
    ' Initialize the form and add the TreeView control to it.
    Me.ClientSize = New Size(292, 273)
    Me.Controls.Add(myTreeView)
End Sub 'New

Comentarios

Esta enumeración se utiliza en el TreeView.DrawMode propiedad para indicar si los nodos o etiquetas de nodo de un TreeView son dibujado por el propietario.This enumeration is used by the TreeView.DrawMode property to indicate whether the nodes or node-labels of a TreeView are owner-drawn. Para obtener más información, vea el evento TreeView.DrawNode.For more information, see the TreeView.DrawNode event.

Se aplica a

Consulte también: