Control.Show メソッド

定義

コントロールをユーザーに対して表示します。Displays the control to the user.

public:
 void Show();
public void Show ();
member this.Show : unit -> unit
Public Sub Show ()

次のコード例では、[バージョン情報] ダイアログボックスを表示し、その画面に一時的に青い四角形を描画します。The following code example displays an about dialog box and temporarily draws a blue square on its surface. この例では、AboutDialogという名前の Form から派生するクラスを定義している必要があります。This example requires that you have defined a class that derives from Form named AboutDialog.

private:
   void menuItemHelpAbout_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      // Create and display a modeless about dialog box.
      AboutDialog^ about = gcnew AboutDialog;
      about->Show();
      
      // Draw a blue square on the form.
      /* NOTE: This is not a persistent object, it will no longer be
                  * visible after the next call to OnPaint. To make it persistent,
                  * override the OnPaint method and draw the square there */
      Graphics^ g = about->CreateGraphics();
      g->FillRectangle( Brushes::Blue, 10, 10, 50, 50 );
   }
private void menuItemHelpAbout_Click(object sender, EventArgs e)
{
   // Create and display a modless about dialog box.
   AboutDialog about = new AboutDialog();
   about.Show();

   // Draw a blue square on the form.
   /* NOTE: This is not a persistent object, it will no longer be
      * visible after the next call to OnPaint. To make it persistent, 
      * override the OnPaint method and draw the square there */
   Graphics g = about.CreateGraphics();
   g.FillRectangle(Brushes.Blue, 10, 10, 50, 50);
}
Private Sub menuItemHelpAbout_Click(sender As Object, _
  e As EventArgs) Handles menuItemHelpAbout.Click
   ' Create and display a modless about dialog box.
   Dim about As New AboutDialog()
   about.Show()
   
   ' Draw a blue square on the form.
   ' NOTE: This is not a persistent object, it will no longer be
   ' visible after the next call to OnPaint. To make it persistent, 
   ' override the OnPaint method and draw the square there 
   Dim g As Graphics = about.CreateGraphics()
   g.FillRectangle(Brushes.Blue, 10, 10, 50, 50)
End Sub

注釈

コントロールを表示することは、Visible プロパティを true に設定することと同じです。Showing the control is equivalent to setting the Visible property to true. Show メソッドが呼び出されると、Hide メソッドが呼び出されるまで、Visible プロパティは true の値を返します。After the Show method is called, the Visible property returns a value of true until the Hide method is called.

適用対象

こちらもご覧ください