Form.WindowState プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As Form Dim value As FormWindowState value = instance.WindowState instance.WindowState = value
public: property FormWindowState WindowState { FormWindowState get (); void set (FormWindowState value); }
/** @property */ public FormWindowState get_WindowState () /** @property */ public void set_WindowState (FormWindowState value)
public function get WindowState () : FormWindowState public function set WindowState (value : FormWindowState)
フォームのウィンドウ状態を表す FormWindowState。既定値は FormWindowState.Normal です。


フォームを表示するには、初期設定値に関係なく、WindowState プロパティを常に FormWindowState.Normal に設定しておきます。この設定は、Height、Left、Top、Width の各プロパティの設定値に反映されます。フォームを一度表示した後に非表示にすると、これらのプロパティには、WindowState プロパティを変更したかどうかに関係なく、フォームが再度表示されるまで前の状態が反映されます。

最上位フォームを作成する方法を次のコード例に示します。この例では、最大化表示されたフォームと最上位フォームの 2 つのフォームを作成します。最初のフォーム bottomForm は WindowState プロパティで最大化表示されています。これにより、最上位フォームの動作がわかりやすくなります。2 番目のフォーム topMostForm は、TopMost プロパティを true に設定することにより、最上位フォームとして表示されます。このコードを実行すると、最大化表示されたフォームをクリックしても、最上位フォームがそのフォームの下に隠れることがなくなります。この例で定義されるメソッドは、他のフォームから呼び出されることを前提にしています。
Private Sub CreateMyTopMostForm() ' Create lower form to display. Dim bottomForm As New Form() ' Display the lower form Maximized to demonstrate effect of TopMost property. bottomForm.WindowState = FormWindowState.Maximized ' Display the bottom form. bottomForm.Show() ' Create the top most form. Dim topMostForm As New Form() ' Set the size of the form larger than the default size. topMostForm.Size = New Size(300, 300) ' Set the position of the top most form to center of screen. topMostForm.StartPosition = FormStartPosition.CenterScreen ' Display the form as top most form. topMostForm.TopMost = True topMostForm.Show() End Sub 'CreateMyTopMostForm
private void CreateMyTopMostForm() { // Create lower form to display. Form bottomForm = new Form(); // Display the lower form Maximized to demonstrate effect of TopMost property. bottomForm.WindowState = FormWindowState.Maximized; // Display the bottom form. bottomForm.Show(); // Create the top most form. Form topMostForm = new Form(); // Set the size of the form larger than the default size. topMostForm.Size = new Size(300,300); // Set the position of the top most form to center of screen. topMostForm.StartPosition = FormStartPosition.CenterScreen; // Display the form as top most form. topMostForm.TopMost = true; topMostForm.Show(); }
private: void CreateMyTopMostForm() { // Create lower form to display. Form^ bottomForm = gcnew Form; // Display the lower form Maximized to demonstrate effect of TopMost property. bottomForm->WindowState = FormWindowState::Maximized; // Display the bottom form. bottomForm->Show(); // Create the top most form. Form^ topMostForm = gcnew Form; // Set the size of the form larger than the default size. topMostForm->Size = System::Drawing::Size( 300, 300 ); // Set the position of the top most form to center of screen. topMostForm->StartPosition = FormStartPosition::CenterScreen; // Display the form as top most form. topMostForm->TopMost = true; topMostForm->Show(); }
private void CreateMyTopMostForm() { // Create lower form to display. Form bottomForm = new Form(); // Display the lower form Maximized to demonstrate effect // of TopMost property. bottomForm.set_WindowState(FormWindowState.Maximized); // Display the bottom form. bottomForm.Show(); // Create the top most form. Form topMostForm = new Form(); // Set the size of the form larger than the default size. topMostForm.set_Size(new Size(300, 300)); // Set the position of the top most form to center of screen. topMostForm.set_StartPosition(FormStartPosition.CenterScreen); // Display the form as top most form. topMostForm.set_TopMost(true); topMostForm.Show(); } //CreateMyTopMostForm

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


FormWindowState 列挙体
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

<ComVisibleAttribute(True)> _ Public Enumeration FormWindowState



この例では、フォームのウィンドウの状態を Maximized に変更し、ラベルを使用して状態情報を表示します。この例は、Form1 という名前の Form が既に作成されていることを前提にしています。
Public Sub InitMyForm() ' Adds a label to the form. Dim label1 As New Label() label1.Location = New System.Drawing.Point(54, 128) label1.Name = "label1" label1.Size = New System.Drawing.Size(220, 80) label1.Text = "Start Position Information" Me.Controls.Add(label1) ' Changes the windows state to Maximized. WindowState = FormWindowState.Maximized ' Displays the window information. label1.Text = "The Form Window is " + WindowState End Sub 'InitMyForm
public void InitMyForm() { // Adds a label to the form. Label label1 = new Label(); label1.Location = new System.Drawing.Point(54, 128); label1.Name = "label1"; label1.Size = new System.Drawing.Size(220, 80); label1.Text = "Start position information"; this.Controls.Add(label1); // Changes the window state to Maximized. WindowState = FormWindowState.Maximized; // Displays the state information. label1.Text = "The form window is " + WindowState; }
public: void InitMyForm() { // Adds a label to the form. Label^ label1 = gcnew Label; label1->Location = System::Drawing::Point( 54, 128 ); label1->Name = "label1"; label1->Size = System::Drawing::Size( 220, 80 ); label1->Text = "Start position information"; this->Controls->Add( label1 ); // Changes the window state to Maximized. WindowState = FormWindowState::Maximized; // Displays the state information. label1->Text = String::Format( "The form window is {0}", WindowState ); }
public void InitMyForm() { // Adds a label to the form. Label label1 = new Label(); label1.set_Location(new System.Drawing.Point(54, 128)); label1.set_Name("label1"); label1.set_Size(new System.Drawing.Size(220, 80)); label1.set_Text("Start position information"); this.get_Controls().Add(label1); // Changes the window state to Maximized. set_WindowState(FormWindowState.Maximized); // Displays the state information. label1.set_Text("The form window is " + get_WindowState()); } //InitMyForm

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からForm.WindowStateを検索する場合は、下記のリンクをクリックしてください。

- Form.WindowStateのページへのリンク