Export (0) Print
Expand All

Splitter.MinSize Property

Gets or sets the minimum distance that must remain between the splitter control and the container edge that the control is docked to.

[Visual Basic]
Public Property MinSize As Integer
[C#]
public int MinSize {get; set;}
[C++]
public: __property int get_MinSize();
public: __property void set_MinSize(int);
[JScript]
public function get MinSize() : int;
public function set MinSize(int);

Property Value

The minimum distance, in pixels, between the Splitter control and the container edge that the control is docked to. The default is 25.

Remarks

For a horizontal Splitter control (a Splitter control docked to the top or bottom of a container), this value is the minimum height of the resizable control. For a vertical Splitter control (a Splitter control docked to the left or right of a container), this value is the minimum width of the resizable control. The user cannot move the splitter past the limit specified by this property.

Note   If the MinSize property is set to a negative value, the property value is reset to 0.

Example

[Visual Basic, C#, C++] The following example uses a Splitter control in combination with TreeView and ListView controls to create a window similar to Windows Explorer. To identify the TreeView and ListView controls, nodes and items are added to both controls. The example uses the MinExtra and MinSize properties of the Splitter to prevent the TreeView or ListView control from being sized too small or too large. This example assumes that the method created in this example is defined within a Form and that the method is called from the constructor of the Form.

[Visual Basic] 
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


[C#] 
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});
}

[C++] 
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(S"TreeView Node");
        listView1->Items->Add(S"ListView Item");

        // Add the controls in reverse order to the form to ensure proper location.

        Control* temp0 [] = {listView1, splitter1, treeView1};
        this->Controls->AddRange(temp0);
    }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Splitter Class | Splitter Members | System.Windows.Forms Namespace | MinExtra

Show:
© 2014 Microsoft