Splitter.MinExtra 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定必須在分隔器控制項和容器對側邊緣 (或停駐於該側的最近控制項) 之間所維持的最短距離。 MinExtra 已經由 SplitContainer 中的類似屬性所取代,而提供它的目的只是為了要保有與舊版之間的相容性。
public:
property int MinExtra { int get(); void set(int value); };
public int MinExtra { get; set; }
member this.MinExtra : int with get, set
Public Property MinExtra As Integer
屬性值
介於 Splitter 控制項與容器對側邊緣 (或停駐於該側的最近控制項) 的最短距離,以像素為單位。 預設值為 25。
範例
下列程式碼範例會搭配 和 ListView 控制項使用 Splitter 控制項 TreeView 來建立類似 Windows 檔案總管的視窗。 為了識別 TreeView 和 ListView 控制項,節點和專案會新增至這兩個控制項。 此範例會使用 MinExtra 的 Splitter 和 MinSize 屬性,以防止 TreeView 或 ListView 控制項的大小太小或太大。 這個範例要求在這個範例中建立的方法是在 內 Form 定義,而且從 的 Form 建構函式呼叫 方法。
private:
void CreateMySplitControls()
{
// Create TreeView, ListView, and Splitter controls.
TreeView^ treeView1 = gcnew TreeView;
ListView^ listView1 = gcnew ListView;
Splitter^ splitter1 = gcnew 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.
array<Control^>^temp0 = {listView1,splitter1,treeView1};
this->Controls->AddRange( temp0 );
}
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});
}
Private Sub CreateMySplitControls()
' Create TreeView, ListView, and Splitter controls.
Dim treeView1 As New TreeView()
Dim listView1 As New ListView()
Dim splitter1 As 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.
Me.Controls.AddRange(New Control() {listView1, splitter1, treeView1})
End Sub
備註
對於水準 Splitter 控制項 (Splitter 停駐到容器頂端或底部的控制項) ,保留給未停駐控制項之容器區域的最小高度是這個值減去控制項的高度 Splitter 。 對於垂直 Splitter 控制項 (Splitter 停駐在容器左邊或右邊的控制項) ,保留給未停駐控制項之容器區域的最小寬度是這個值減去控制項的 Splitter 寬度。 使用者無法移動分隔器超過此屬性所指定的限制。
注意
MinExtra如果屬性設定為負值,屬性值會重設為 0。