Control.Show 方法

定義

對使用者顯示控制項。

C#
public void Show ();

範例

下列程式碼範例會顯示關於對話方塊的 ,並暫時在其介面上繪製藍色方塊。 此範例要求您已定義衍生自 Form 具名 AboutDialog 的類別。

C#
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);
}

備註

顯示控制項相當於將 Visible 屬性設定為 trueShow呼叫 方法之後, Visible 屬性會傳回 的值 true ,直到 Hide 呼叫 方法為止。

適用於

產品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

另請參閱