SplitContainer.Panel1MinSize 属性

定义

获取或设置拆分器与 Panel1 的左边缘或上边缘的最小距离(以像素为单位)。

C#
public int Panel1MinSize { get; set; }

属性值

Int32

Int32,它表示拆分器离 Panel1 的左边缘或上边缘的最小距离(以像素为单位)。 不管 Orientation 为何值,默认值均为 25 像素。

例外

指定的值与方向不一致。

示例

下面的代码示例显示了垂直拆分器,其中左面板 (最小大小的 Panel1) 设置为 30 像素,现在拆分器可以从容器的左边缘最小距离。 还显示了垂直拆分器的其他基本属性。 此示例是为类提供的大型示例的 SplitContainer 一部分。

C#
// 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;

注解

使用该 Panel1MinSize 属性可防止拆分器太接近容器的左边缘或上边缘移动。 例如,你可能想要阻止覆盖部分 TreeView 显示区域。

Orientation如果属性Vertical (默认) ,Panel1MinSize则从左边缘Panel1返回拆分器的最低距离(以像素为单位)。 如果属性是OrientationHorizontalPanel1MinSize则返回从上边缘Panel1的拆分器最小距离(以像素为单位)。

适用于

产品 版本
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

另请参阅