Control.Show メソッド
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
解説
コントロールを表示することは、Visible プロパティを true に設定することと同じです。Show メソッドが呼び出された後、Visible プロパティは Hide メソッドが呼び出されるまで、true の値を返します。
説明のダイアログ ボックスを表示して、その表面に青い正方形を一時的に描画するコード例を次に示します。この例では、Form から派生した AboutDialog という名前のクラスが定義されていることが必要です。
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
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: 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.get_Blue(), 10, 10, 50, 50); } //menuItemHelpAbout_Click
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- Control.Show メソッドのページへのリンク