Splitter.MinSize 屬性

定義

取得或設定必須在分隔器控制項和該控制項停駐所在的容器邊緣之間維持的最小距離。 MinSize 已經由 Panel1MinSizePanel2MinSize 所取代,而提供它的目的只是為了要保有與舊版之間的相容性。

C#
public int MinSize { get; set; }

屬性值

Int32

以像素為單位的最短距離,介於 Splitter 控制項與控制項所停駐的容器邊緣之間。 預設值為 25。

範例

下列程式碼範例會搭配 和 ListView 控制項使用 Splitter 控制項 TreeView 來建立類似 Windows Explorer 的視窗。 為了識別 TreeViewListView 控制項,節點和專案會新增至這兩個控制項。 此範例會使用 MinExtraSplitterMinSize 屬性,以防止 TreeViewListView 控制項的大小太小或太大。 這個範例要求在這個範例中建立的方法是在 內 Form 定義,而且從 的 Form 建構函式呼叫 方法。

C#
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});
}

備註

對於水準 Splitter 控制項 (Splitter 停駐到容器頂端或底部的控制項) ,此值是可調整大小的控制項的最小高度。 對於垂直 Splitter 控制項 (Splitter 停駐在容器) 左邊或右邊的控制項,這個值是可調整大小的控制項的最小寬度。 使用者無法移動分隔器超過此屬性所指定的限制。

注意

MinSize如果屬性設定為負值,屬性值會重設為 0。

適用於

產品 版本
.NET Framework 1.1, 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

另請參閱