Splitter Constructor

Definición

Inicializa una nueva instancia de la clase Splitter.Initializes a new instance of the Splitter class. El control Splitter ha sido reemplazado por el control SplitContainer, y únicamente se proporciona para ofrecer compatibilidad con versiones anteriores.Splitter has been replaced by SplitContainer, and is provided only for compatibility with previous versions.

public:
 Splitter();
public Splitter ();
Public Sub New ()

Ejemplos

En el ejemplo de código siguiente se usa un control de Splitter en combinación con los controles TreeView y ListView para crear una ventana similar a la del explorador de Windows.The following code example uses a Splitter control in combination with TreeView and ListView controls to create a window similar to Windows Explorer. Para identificar los controles TreeView y ListView, los nodos y elementos se agregan a ambos controles.To identify the TreeView and ListView controls, nodes and items are added to both controls. En el ejemplo se usan las propiedades MinExtra y MinSize de la Splitter para evitar que el control TreeView o ListView tenga un tamaño demasiado pequeño o demasiado grande.The example uses the MinExtra and MinSize properties of the Splitter to prevent the TreeView or ListView control from being sized too small or too large. Este ejemplo requiere que el método creado en este ejemplo esté definido dentro de una Form y que se llame al método desde el constructor de la Form.This example requires that the method created in this example is defined within a Form and that the method is called from the constructor of the Form.

private:
   void CreateMySplitControls()
   {
      // Create TreeView, ListView, and Splitter controls.
      TreeView^ treeView1 = gcnew TreeView;
      ListView^ listView1 = gcnew ListView;
      Splitter^ splitter1 = gcnew Splitter;

      // Set the TreeView control to dock to the left side of the form.
      treeView1->Dock = DockStyle::Left;

      // Set the Splitter to dock to the left side of the TreeView control.
      splitter1->Dock = DockStyle::Left;

      // Set the minimum size the ListView control can be sized to.
      splitter1->MinExtra = 100;

      // Set the minimum size the TreeView control can be sized to.
      splitter1->MinSize = 75;

      // Set the ListView control to fill the remaining space on the form.
      listView1->Dock = DockStyle::Fill;

      // Add a TreeView and a ListView item to identify the controls on the form.
      treeView1->Nodes->Add( "TreeView Node" );
      listView1->Items->Add( "ListView Item" );

      // Add the controls in reverse order to the form to ensure proper location.
      array<Control^>^temp0 = {listView1,splitter1,treeView1};
      this->Controls->AddRange( temp0 );
   }
private void CreateMySplitControls()
{
    // Create TreeView, ListView, and Splitter controls.
    TreeView treeView1 = new TreeView();
    ListView listView1 = new ListView();
    Splitter splitter1 = new Splitter();

    // Set the TreeView control to dock to the left side of the form.
    treeView1.Dock = DockStyle.Left;
    // Set the Splitter to dock to the left side of the TreeView control.
    splitter1.Dock = DockStyle.Left;
    // Set the minimum size the ListView control can be sized to.
    splitter1.MinExtra = 100;
    // Set the minimum size the TreeView control can be sized to.
    splitter1.MinSize = 75;
    // Set the ListView control to fill the remaining space on the form.
    listView1.Dock = DockStyle.Fill;
    // Add a TreeView and a ListView item to identify the controls on the form.
    treeView1.Nodes.Add("TreeView Node");
    listView1.Items.Add("ListView Item");

    // Add the controls in reverse order to the form to ensure proper location.
    this.Controls.AddRange(new Control[]{listView1, splitter1, treeView1});
}
Private Sub CreateMySplitControls()
   ' Create TreeView, ListView, and Splitter controls.
   Dim treeView1 As New TreeView()
   Dim listView1 As New ListView()
   Dim splitter1 As New Splitter()
   
   ' Set the TreeView control to dock to the left side of the form.
   treeView1.Dock = DockStyle.Left
   ' Set the Splitter to dock to the left side of the TreeView control.
   splitter1.Dock = DockStyle.Left
   ' Set the minimum size the ListView control can be sized to.
      splitter1.MinExtra = 100
   ' Set the minimum size the TreeView control can be sized to.
      splitter1.MinSize = 75
   ' Set the ListView control to fill the remaining space on the form.
      listView1.Dock = DockStyle.Fill

      ' Add a TreeView and a ListView item to identify the controls on the form.
      treeView1.Nodes.Add("TreeView Node")
      listView1.Items.Add("ListView Item")
   
   ' Add the controls in reverse order to the form to ensure proper location.
   Me.Controls.AddRange(New Control() {listView1, splitter1, treeView1})
End Sub

Comentarios

De forma predeterminada, las propiedades MinSize y MinExtra se establecen en 25.By default, the MinSize and MinExtra properties are set to 25. De forma predeterminada, la propiedad Dock está establecida en DockStyle.Left.The Dock property is set to DockStyle.Left by default.

Se aplica a