Form.TopMost プロパティとは? わかりやすく解説

Form.TopMost プロパティ

フォーム最上位フォームとして表示するかどうかを示す値を取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説
使用例使用例

最上位フォーム作成するコード例次に示します。この例では、最大化表示されフォーム最上位フォーム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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

Form.TopMost プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Form.TopMost プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS