Splitter.MinExtra 屬性

定義

取得或設定必須在分隔器控制項和容器對側邊緣 (或停駐於該側的最近控制項) 之間所維持的最短距離。 MinExtra 已經由 SplitContainer 中的類似屬性所取代,而提供它的目的只是為了要保有與舊版之間的相容性。

C#
public int MinExtra { get; set; }

屬性值

介於 Splitter 控制項與容器對側邊緣 (或停駐於該側的最近控制項) 的最短距離,以像素為單位。 預設值為 25。

範例

下列程式碼範例會搭配 和 ListView 控制項使用 Splitter 控制項 TreeView 來建立類似 Windows 檔案總管的視窗。 為了識別 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 控制項 (Splitter 停駐在容器左邊或右邊的控制項) ,保留給未停駐控制項之容器區域的最小寬度是這個值減去控制項的 Splitter 寬度。 使用者無法移動分隔器超過此屬性所指定的限制。

注意

MinExtra如果屬性設定為負值,屬性值會重設為 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, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

另請參閱