Splitter.MinExtra 属性

定义

获取或设置在拆分器控件与容器另一侧的边缘(或停靠到该侧的最近控件)之间必须保留的最小距离。 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。

示例

下面的代码示例将 Splitter 控件与 TreeViewListView 控件结合使用,以创建类似于 Windows 资源管理器的窗口。 为了标识 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 控件 (Splitter 停靠在容器) 左侧或右侧的控件,为未停靠控件保留的容器区域的最小宽度是此值减去控件的 Splitter 宽度。 用户无法将拆分器移动超过此属性指定的限制。

注意

MinExtra如果该属性设置为负值,则属性值将重置为 0。

适用于

另请参阅