Splitter.MinSize Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает или задает минимальное расстояние, которое должно оставаться между элементом управления разделением и краем контейнера, к которому закреплен элемент управления. MinSize заменено Panel1MinSize и Panel2MinSize предоставляется только для совместимости с предыдущими версиями.
public:
property int MinSize { int get(); void set(int value); };
public int MinSize { get; set; }
member this.MinSize : int with get, set
Public Property MinSize As Integer
Значение свойства
Минимальное расстояние в пикселях между элементом Splitter управления и краем контейнера, к которому закреплен элемент управления. Значение по умолчанию — 25.
Примеры
В следующем примере кода элемент управления используется Splitter в сочетании с TreeView элементами управления для ListView создания окна, аналогичного проводнику Windows. Для идентификации TreeView и элементов управления узлы и ListView элементы добавляются в оба элемента управления. В примере используются MinExtra свойства и MinSize свойства Splitter , чтобы предотвратить 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 элемент управления, закрепленный слева или справа от контейнера), это значение является минимальной шириной элемента управления с изменением размера. Пользователь не может переместить разделитель в прошлое ограничение, указанное этим свойством.
Замечание
MinSize Если для свойства задано отрицательное значение, значение свойства сбрасывается до 0.