SplitContainer.SplitterDistance Eigenschaft

Definition

Ruft die Position des Splitters in Pixel in Bezug auf den linken oder oberen Rand von SplitContainer ab oder legt diese fest.

public:
 property int SplitterDistance { int get(); void set(int value); };
[System.ComponentModel.SettingsBindable(true)]
public int SplitterDistance { get; set; }
[<System.ComponentModel.SettingsBindable(true)>]
member this.SplitterDistance : int with get, set
Public Property SplitterDistance As Integer

Eigenschaftswert

Eine Int32, die die Position des Splitters in Bezug auf den linken oder oberen Rand von SplitContainer in Pixel darstellt. Der Standardwert ist 50 Pixel.

Attribute

Ausnahmen

Der Wert ist kleiner als 0 (null).

Der Wert ist mit der Ausrichtung nicht kompatibel.

Beispiele

Im folgenden Codebeispiel wird angegeben, dass der anfängliche Abstand des vertikalen Splitters vom linken Rand des Containers 79 Pixel beträgt. Weitere grundlegende Eigenschaften eines vertikalen Splitters werden ebenfalls angezeigt. Dieses Beispiel ist Teil eines größeren Beispiels, das für die SplitContainer -Klasse bereitgestellt wird.

// Basic SplitContainer properties.
// This is a vertical splitter that moves in 10-pixel increments.
// This splitter needs no explicit Orientation property because Vertical is the default.
splitContainer1->Dock = System::Windows::Forms::DockStyle::Fill;
splitContainer1->ForeColor = System::Drawing::SystemColors::Control;
splitContainer1->Location = System::Drawing::Point( 0, 0 );
splitContainer1->Name = "splitContainer1";

// You can drag the splitter no nearer than 30 pixels from the left edge of the container.
splitContainer1->Panel1MinSize = 30;

// You can drag the splitter no nearer than 20 pixels from the right edge of the container.
splitContainer1->Panel2MinSize = 20;
splitContainer1->Size = System::Drawing::Size( 292, 273 );
splitContainer1->SplitterDistance = 79;

// This splitter moves in 10-pixel increments.
splitContainer1->SplitterIncrement = 10;
splitContainer1->SplitterWidth = 6;

// splitContainer1 is the first control in the tab order.
splitContainer1->TabIndex = 0;
splitContainer1->Text = "splitContainer1";

// When the splitter moves, the cursor changes shape.
splitContainer1->SplitterMoved += gcnew System::Windows::Forms::SplitterEventHandler( this, &Form1::splitContainer1_SplitterMoved );
splitContainer1->SplitterMoving += gcnew System::Windows::Forms::SplitterCancelEventHandler( this, &Form1::splitContainer1_SplitterMoving );

// Add a TreeView control to the left panel.
splitContainer1->Panel1->BackColor = System::Drawing::SystemColors::Control;

// Add a TreeView control to Panel1.
splitContainer1->Panel1->Controls->Add( treeView1 );
splitContainer1->Panel1->Name = "splitterPanel1";

// Controls placed on Panel1 support right-to-left fonts.
splitContainer1->Panel1->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
// Basic SplitContainer properties.
// This is a vertical splitter that moves in 10-pixel increments.
// This splitter needs no explicit Orientation property because Vertical is the default.
splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
splitContainer1.ForeColor = System.Drawing.SystemColors.Control;
splitContainer1.Location = new System.Drawing.Point(0, 0);
splitContainer1.Name = "splitContainer1";
// You can drag the splitter no nearer than 30 pixels from the left edge of the container.
splitContainer1.Panel1MinSize = 30;
// You can drag the splitter no nearer than 20 pixels from the right edge of the container.
splitContainer1.Panel2MinSize = 20;
splitContainer1.Size = new System.Drawing.Size(292, 273);
splitContainer1.SplitterDistance = 79;
// This splitter moves in 10-pixel increments.
splitContainer1.SplitterIncrement = 10;
splitContainer1.SplitterWidth = 6;
// splitContainer1 is the first control in the tab order.
splitContainer1.TabIndex = 0;
splitContainer1.Text = "splitContainer1";
// When the splitter moves, the cursor changes shape.
splitContainer1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(splitContainer1_SplitterMoved);
splitContainer1.SplitterMoving += new System.Windows.Forms.SplitterCancelEventHandler(splitContainer1_SplitterMoving);

// Add a TreeView control to the left panel.
splitContainer1.Panel1.BackColor = System.Drawing.SystemColors.Control;
// Add a TreeView control to Panel1.
splitContainer1.Panel1.Controls.Add(treeView1);
splitContainer1.Panel1.Name = "splitterPanel1";
// Controls placed on Panel1 support right-to-left fonts.
splitContainer1.Panel1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
' Basic SplitContainer properties.
' This is a vertical splitter that moves in 10-pixel increments.
' This splitter needs no explicit Orientation property because Vertical is the default.
splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill
splitContainer1.ForeColor = System.Drawing.SystemColors.Control
splitContainer1.Location = New System.Drawing.Point(0, 0)
splitContainer1.Name = "splitContainer1"
' You can drag the splitter no nearer than 30 pixels from the left edge of the container.
splitContainer1.Panel1MinSize = 30
' You can drag the splitter no nearer than 20 pixels from the right edge of the container.
splitContainer1.Panel2MinSize = 20
splitContainer1.Size = New System.Drawing.Size(292, 273)
splitContainer1.SplitterDistance = 79
' This splitter moves in 10-pixel increments.
splitContainer1.SplitterIncrement = 10
splitContainer1.SplitterWidth = 6
' splitContainer1 is the first control in the tab order.
splitContainer1.TabIndex = 0
splitContainer1.Text = "splitContainer1"
  
' Add a TreeView control to the left panel.
splitContainer1.Panel1.BackColor = System.Drawing.SystemColors.Control
' Add a TreeView control to Panel1.
splitContainer1.Panel1.Controls.Add(treeView1)
splitContainer1.Panel1.Name = "splitterPanel1"
' Controls placed on Panel1 support right-to-left fonts.
splitContainer1.Panel1.RightToLeft = System.Windows.Forms.RightToLeft.Yes

Hinweise

Verwenden Sie die SplitterDistance -Eigenschaft, um den Abstand des Splitters vom linken oder oberen Rand des Containers in Pixel zu bestimmen oder anzugeben. Sie können beide eine anfängliche Entfernung angeben und die Entfernung zur Entwurfszeit oder Zur Laufzeit ändern. Wenn Orientation ist Horizontal, SplitterDistance wird in Pixeln vom oberen Rand des SplitContainerberechnet. Wenn Orientation ist Vertical, SplitterDistance wird in Pixeln vom linken Rand des SplitContainerberechnet.

Gilt für:

Weitere Informationen