SplitContainer.Panel2MinSize 属性

定义

获取或设置拆分器离 Panel2 的右边缘或下边缘的最小距离(以像素为单位)。Gets or sets the minimum distance in pixels of the splitter from the right or bottom edge of Panel2.

public:
 property int Panel2MinSize { int get(); void set(int value); };
public int Panel2MinSize { get; set; }
member this.Panel2MinSize : int with get, set
Public Property Panel2MinSize As Integer

属性值

Int32,它表示拆分器离 Panel2 的右边缘或下边缘的最小距离(以像素为单位)。An Int32 representing the minimum distance in pixels of the splitter from the right or bottom edge of Panel2. 不管 Orientation 为何值,默认值均为 25 像素。The default value is 25 pixels, regardless of Orientation.

异常

指定的值与方向不一致。The specified value is incompatible with the orientation.

示例

下面的代码示例演示了一个垂直拆分器,其中 Panel2 的最小大小(右面板)设置为20个像素,这现在是拆分器可以从容器的右边缘的最小距离。The following code example shows a vertical splitter where the minimum size of Panel2 (the right panel) is set to 20 pixels, which is now the minimum distance the splitter can be from the right edge of the container. 还显示了垂直拆分器的其他基本属性。Other basic properties of a vertical splitter are also shown. 此示例是为 SplitContainer 类提供的更大示例的一部分。This example is part of a larger example provided for the SplitContainer class.

// 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

注解

使用 Panel2MinSize 属性可防止拆分器移动到容器的右边缘或下边缘附近。Use the Panel2MinSize property to prevent the splitter from moving too close to the right or bottom edge of the container. 例如,你可能想要防止覆盖 TreeView 的某些显示区域。For example, you might want to prevent some of the display area of a TreeView from being covered.

如果 Orientation 属性为 Vertical (默认值),则 Panel2MinSize 会返回拆分器可以从 Panel2右边缘的最小距离(以像素为单位)。If the Orientation property is Vertical (the default), Panel2MinSize returns the minimum distance in pixels that the splitter can be from the right edge of Panel2. 如果 HorizontalOrientation 属性,Panel2MinSize 将以像素为单位返回拆分器可以从 Panel2下边缘的最小距离(以像素为单位)。If the Orientation property is Horizontal, Panel2MinSize returns the minimum distance in pixels that the splitter can be from the bottom edge of Panel2.

适用于

另请参阅