Splitter.MinExtra 属性

获取或设置拆分器控件和容器(或停靠到离该侧最近的控件)另一侧边缘之间必须保留的最小距离。Splitter.MinExtra 已被 System.Windows.Forms.SplitContainer 中的类似属性取代,且仅为与早期版本兼容而提供。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
<LocalizableAttribute(True)> _
Public Property MinExtra As Integer
用法
Dim instance As Splitter
Dim value As Integer

value = instance.MinExtra

instance.MinExtra = value
[LocalizableAttribute(true)] 
public int MinExtra { get; set; }
[LocalizableAttribute(true)] 
public:
property int MinExtra {
    int get ();
    void set (int value);
}
/** @property */
public int get_MinExtra ()

/** @property */
public void set_MinExtra (int value)
public function get MinExtra () : int

public function set MinExtra (value : int)

属性值

Splitter 控件与容器另一侧的边缘(或停靠到该侧的最近控件)之间的最小距离,以像素表示。默认值为 25。

备注

对于水平 Splitter 控件(停靠到容器顶部或底部的 Splitter 控件),容器中为未停靠的控件保留的区域的最小高度为此值减去 Splitter 控件的高度。对于垂直 Splitter 控件(停靠到容器左侧或右侧的 Splitter 控件),为未停靠的控件保留的容器区域的最小宽度为此值减去 Splitter 控件的宽度。用户移动拆分器不能超过此属性指定的限制。

提示

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

示例

下面的代码示例将 Splitter 控件与 TreeViewListView 控件一起使用,来创建与 Windows 资源管理器类似的窗口。若要标识 TreeViewListView 控件,向这两个控件添加节点和项。该示例使用 SplitterMinExtraMinSize 属性,以防止将 TreeViewListView 控件调整得太小或太大。此示例要求在 Form 中定义在此示例中创建的方法,并要求从 Form 的构造函数中调用该方法。

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 'CreateMySplitControls
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:
   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.set_Dock(DockStyle.Left);
    // Set the Splitter to dock to the left side of the TreeView control.
    splitter1.set_Dock(DockStyle.Left);
    // Set the minimum size the ListView control can be sized to.
    splitter1.set_MinExtra(100);
    // Set the minimum size the TreeView control can be sized to.
    splitter1.set_MinSize(75);
    // Set the ListView control to fill the remaining space on the form.
    listView1.set_Dock(DockStyle.Fill);
    // Add a TreeView and a ListView item to identify the controls on the 
    // form.
    treeView1.get_Nodes().Add("TreeView Node");
    listView1.get_Items().Add("ListView Item");
    // Add the controls in reverse order to the form to ensure proper 
    // location.
    this.get_Controls().AddRange(new Control[] { listView1, splitter1, 
        treeView1 });
} //CreateMySplitControls

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0

请参见

参考

Splitter 类
Splitter 成员
System.Windows.Forms 命名空间
MinSize