Bagikan melalui


Splitter.MinExtra Properti

Definisi

Mendapatkan atau mengatur jarak minimum yang harus tetap berada di antara kontrol pemisah dan tepi sisi kontainer yang berlawanan (atau kontrol terdekat yang ditambatkan ke sisi tersebut). MinExtra telah digantikan oleh properti serupa di dan SplitContainer disediakan hanya untuk kompatibilitas dengan versi sebelumnya.

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

Nilai Properti

Jarak minimum, dalam piksel, antara Splitter kontrol dan tepi sisi kontainer yang berlawanan (atau kontrol terdekat yang ditambatkan ke sisi tersebut). Defaultnya adalah 25.

Contoh

Contoh kode berikut menggunakan Splitter kontrol dalam kombinasi dengan TreeView kontrol dan ListView untuk membuat jendela yang mirip dengan Windows Explorer. Untuk mengidentifikasi TreeView kontrol dan ListView , simpul dan item ditambahkan ke kedua kontrol. Contoh menggunakan MinExtra properti dan MinSize untuk Splitter mencegah TreeView atau ListView kontrol berukuran terlalu kecil atau terlalu besar. Contoh ini mengharuskan metode yang dibuat dalam contoh ini didefinisikan dalam dan Form bahwa metode dipanggil dari konstruktor 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

Keterangan

Untuk kontrol horizontal Splitter (kontrol yang Splitter ditampar ke bagian atas atau bawah kontainer), tinggi minimum area kontainer yang dicadangkan untuk kontrol yang tidak ditautkan adalah nilai ini dikurangi Splitter tinggi kontrol. Untuk kontrol vertikal Splitter (kontrol yang Splitter ditampar ke kiri atau kanan kontainer), lebar minimum area kontainer yang dicadangkan untuk kontrol yang tidak ditautkan adalah nilai ini dikurangi Splitter lebar kontrol. Pengguna tidak dapat memindahkan pemisah melewati batas yang ditentukan oleh properti ini.

Nota

MinExtra Jika properti diatur ke nilai negatif, nilai properti diatur ulang ke 0.

Berlaku untuk

Lihat juga