共用方式為


Splitter.MinSize 屬性

定義

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

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

屬性值

Int32

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

範例

下列程式碼範例會搭配 和 ListView 控制項使用 Splitter 控制項 TreeView 來建立類似 Windows Explorer 的視窗。 為了識別 TreeViewListView 控制項,節點和專案會新增至這兩個控制項。 此範例會使用 MinExtraSplitterMinSize 屬性,以防止 TreeViewListView 控制項的大小太小或太大。 這個範例要求在這個範例中建立的方法是在 內 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 停駐在容器) 左邊或右邊的控制項,這個值是可調整大小的控制項的最小寬度。 使用者無法移動分隔器超過此屬性所指定的限制。

注意

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

適用於

另請參閱