Form.MinimizeBox 属性
获取或设置一个值,该值指示是否在窗体的标题栏中显示“最小化”按钮。
**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)
语法
声明
Public Property MinimizeBox As Boolean
用法
Dim instance As Form
Dim value As Boolean
value = instance.MinimizeBox
instance.MinimizeBox = value
public bool MinimizeBox { get; set; }
public:
property bool MinimizeBox {
bool get ();
void set (bool value);
}
/** @property */
public boolean get_MinimizeBox ()
/** @property */
public void set_MinimizeBox (boolean value)
public function get MinimizeBox () : boolean
public function set MinimizeBox (value : boolean)
属性值
如果为 true,则显示窗体的“最小化”按钮;否则为 false。默认为 true。
备注
“最小化”按钮使用户得以将窗口最小化为图标。若要显示“最小化”按钮,还必须将窗体的 FormBorderStyle 属性设置为 FormBorderStyle.FixedSingle、FormBorderStyle.Sizable、FormBorderStyle.Fixed3D 或 FormBorderStyle.FixedDialog。
提示
在运行时最小化窗体会生成 Resize 事件。WindowState 属性反映窗口的当前状态。如果将 WindowState 属性设置为 FormWindowState.Minimized,则窗体是最小化的,而不论对于 MinimizeBox 和 FormBorderStyle 属性什么设置生效。
示例
下面的代码示例创建 Form 的一个新实例,并调用 ShowDialog 方法以将该窗体显示为对话框。该示例设置 FormBorderStyle、AcceptButton、CancelButton、MinimizeBox、MaximizeBox 和 StartPosition 属性,将窗体的外观和功能更改为对话框形式。该示例还使用窗体的 Controls 集合的 Add 方法来添加两个 Button 控件。该示例使用 HelpButton 属性来在对话框的标题栏中显示“帮助”按钮。
Public Sub CreateMyForm()
' Create a new instance of the form.
Dim form1 As New Form()
' Create two buttons to use as the accept and cancel buttons.
Dim button1 As New Button()
Dim button2 As New Button()
' Set the text of button1 to "OK".
button1.Text = "OK"
' Set the position of the button on the form.
button1.Location = New Point(10, 10)
' Set the text of button2 to "Cancel".
button2.Text = "Cancel"
' Set the position of the button based on the location of button1.
button2.Location = _
New Point(button1.Left, button1.Height + button1.Top + 10)
' Set the caption bar text of the form.
form1.Text = "My Dialog Box"
' Display a help button on the form.
form1.HelpButton = True
' Define the border style of the form to a dialog box.
form1.FormBorderStyle = FormBorderStyle.FixedDialog
' Set the MaximizeBox to false to remove the maximize box.
form1.MaximizeBox = False
' Set the MinimizeBox to false to remove the minimize box.
form1.MinimizeBox = False
' Set the accept button of the form to button1.
form1.AcceptButton = button1
' Set the cancel button of the form to button2.
form1.CancelButton = button2
' Set the start position of the form to the center of the screen.
form1.StartPosition = FormStartPosition.CenterScreen
' Add button1 to the form.
form1.Controls.Add(button1)
' Add button2 to the form.
form1.Controls.Add(button2)
' Display the form as a modal dialog box.
form1.ShowDialog()
End Sub
public void CreateMyForm()
{
// Create a new instance of the form.
Form form1 = new Form();
// Create two buttons to use as the accept and cancel buttons.
Button button1 = new Button ();
Button button2 = new Button ();
// Set the text of button1 to "OK".
button1.Text = "OK";
// Set the position of the button on the form.
button1.Location = new Point (10, 10);
// Set the text of button2 to "Cancel".
button2.Text = "Cancel";
// Set the position of the button based on the location of button1.
button2.Location
= new Point (button1.Left, button1.Height + button1.Top + 10);
// Set the caption bar text of the form.
form1.Text = "My Dialog Box";
// Display a help button on the form.
form1.HelpButton = true;
// Define the border style of the form to a dialog box.
form1.FormBorderStyle = FormBorderStyle.FixedDialog;
// Set the MaximizeBox to false to remove the maximize box.
form1.MaximizeBox = false;
// Set the MinimizeBox to false to remove the minimize box.
form1.MinimizeBox = false;
// Set the accept button of the form to button1.
form1.AcceptButton = button1;
// Set the cancel button of the form to button2.
form1.CancelButton = button2;
// Set the start position of the form to the center of the screen.
form1.StartPosition = FormStartPosition.CenterScreen;
// Add button1 to the form.
form1.Controls.Add(button1);
// Add button2 to the form.
form1.Controls.Add(button2);
// Display the form as a modal dialog box.
form1.ShowDialog();
}
public:
void CreateMyForm()
{
// Create a new instance of the form.
Form^ form1 = gcnew Form;
// Create two buttons to use as the accept and cancel buttons.
Button^ button1 = gcnew Button;
Button^ button2 = gcnew Button;
// Set the text of button1 to "OK".
button1->Text = "OK";
// Set the position of the button on the form.
button1->Location = Point(10,10);
// Set the text of button2 to "Cancel".
button2->Text = "Cancel";
// Set the position of the button based on the location of button1.
button2->Location =
Point( button1->Left, button1->Height + button1->Top + 10 );
// Set the caption bar text of the form.
form1->Text = "My Dialog Box";
// Display a help button on the form.
form1->HelpButton = true;
// Define the border style of the form to a dialog box.
form1->FormBorderStyle = ::FormBorderStyle::FixedDialog;
// Set the MaximizeBox to false to remove the maximize box.
form1->MaximizeBox = false;
// Set the MinimizeBox to false to remove the minimize box.
form1->MinimizeBox = false;
// Set the accept button of the form to button1.
form1->AcceptButton = button1;
// Set the cancel button of the form to button2.
form1->CancelButton = button2;
// Set the start position of the form to the center of the screen.
form1->StartPosition = FormStartPosition::CenterScreen;
// Add button1 to the form.
form1->Controls->Add( button1 );
// Add button2 to the form.
form1->Controls->Add( button2 );
// Display the form as a modal dialog box.
form1->ShowDialog();
}
public void CreateMyForm()
{
// Create a new instance of the form.
Form form1 = new Form();
// Create two buttons to use as the accept and cancel buttons.
Button button1 = new Button();
Button button2 = new Button();
// Set the text of button1 to "OK".
button1.set_Text("OK");
// Set the position of the button on the form.
button1.set_Location(new Point(10, 10));
// Set the text of button2 to "Cancel".
button2.set_Text("Cancel");
// Set the position of the button based on the location of button1.
button2.set_Location(new Point(button1.get_Left(),
button1.get_Height() + button1.get_Top() + 10));
// Set the caption bar text of the form.
form1.set_Text("My Dialog Box");
// Display a help button on the form.
form1.set_HelpButton(true);
// Define the border style of the form to a dialog box.
form1.set_FormBorderStyle(get_FormBorderStyle().FixedDialog);
// Set the MaximizeBox to false to remove the maximize box.
form1.set_MaximizeBox(false);
// Set the MinimizeBox to false to remove the minimize box.
form1.set_MinimizeBox(false);
// Set the accept button of the form to button1.
form1.set_AcceptButton(button1);
// Set the cancel button of the form to button2.
form1.set_CancelButton(button2);
// Set the start position of the form to the center of the screen.
form1.set_StartPosition(FormStartPosition.CenterScreen);
// Add button1 to the form.
form1.get_Controls().Add(button1);
// Add button2 to the form.
form1.get_Controls().Add(button2);
// Display the form as a modal dialog box.
form1.ShowDialog();
} //CreateMyForm
平台
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、1.0
请参见
参考
Form 类
Form 成员
System.Windows.Forms 命名空间
Form.MaximizeBox 属性
Form.ControlBox 属性