Splitter.MinSize 属性

获取或设置拆分器控件和控件停靠的容器边缘之间必须保持的最小距离。Splitter.MinSize 已被 SplitContainer.Panel1MinSizeSplitContainer.Panel2MinSize 取代,并仅为与早期版本兼容而提供。

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

语法

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

value = instance.MinSize

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

/** @property */
public void set_MinSize (int value)
public function get MinSize () : int

public function set MinSize (value : int)

属性值

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

备注

对于水平 Splitter 控件(停靠到容器顶部或底部的 Splitter 控件),此值是可调整大小控件的最小高度。对于垂直 Splitter 控件(停靠到容器左侧或右侧的 Splitter 控件),此值是可调整大小控件的最小宽度。用户移动拆分器不能超过此属性指定的限制。

提示

如果 MinSize 属性设置为负值,则该属性值将重置为 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 命名空间
Splitter.MinExtra 属性