Form.ShowInTaskbar 属性

定义

获取或设置一个值,该值指示是否在 Windows 任务栏中显示窗体。Gets or sets a value indicating whether the form is displayed in the Windows taskbar.

public:
 property bool ShowInTaskbar { bool get(); void set(bool value); };
public bool ShowInTaskbar { get; set; }
member this.ShowInTaskbar : bool with get, set
Public Property ShowInTaskbar As Boolean

属性值

如果为 true,则运行时在 Windows 任务栏中显示窗体;否则,为 falsetrue to display the form in the Windows taskbar at run time; otherwise, false. 默认值为 trueThe default is true.

示例

下面的示例演示如何使用 ShowInTaskbar 属性生成一个不在 Windows 任务栏中显示的对话框。The following example demonstrates how to use the ShowInTaskbar property to make a dialog box that is not displayed in the Windows taskbar.

private:
   void ShowInTaskBarEx()
   {
      Form^ myForm = gcnew Form;
      myForm->Text = "My Form";
      myForm->SetBounds( 10, 10, 200, 200 );
      myForm->FormBorderStyle = ::FormBorderStyle::FixedDialog;
      myForm->MinimizeBox = false;
      myForm->MaximizeBox = false;

      // Do not allow form to be displayed in taskbar.
      myForm->ShowInTaskbar = false;
      myForm->ShowDialog();
   }
private void ShowInTaskBarEx()
{
    Form myForm = new Form();
    myForm.Text = "My Form";
    myForm.SetBounds(10,10,200,200);
    myForm.FormBorderStyle = FormBorderStyle.FixedDialog;
    myForm.MinimizeBox = false;
    myForm.MaximizeBox = false;
    // Do not allow form to be displayed in taskbar.
    myForm.ShowInTaskbar = false;
    myForm.ShowDialog();
}
Private Sub ShowInTaskBarEx()
    Dim myForm As New Form()
    myForm.Text = "My Form"
    myForm.SetBounds(10, 10, 200, 200)
    myForm.FormBorderStyle = FormBorderStyle.FixedDialog
    myForm.MinimizeBox = False
    myForm.MaximizeBox = False
    ' Do not allow form to be displayed in taskbar.
    myForm.ShowInTaskbar = False
    myForm.ShowDialog()
End Sub

注解

如果窗体是其他窗体中的父级,则不会在 Windows 任务栏中显示父级窗体。If a form is parented within another form, the parented form is not displayed in the Windows taskbar.

可以使用此属性来防止用户通过 Windows 任务栏选择窗体。You can use this property to prevent users from selecting your form through the Windows taskbar. 例如,如果您在应用程序中显示 "查找和替换" 工具窗口,则您可能希望阻止通过 Windows 任务栏选择该窗口,因为您将需要应用程序的主窗口和 "查找和替换" 工具窗口显示以便适当地处理搜索。For example, if you display a Find and Replace tool window in your application, you might want to prevent that window from being selected through the Windows taskbar because you would need both the application's main window and the Find and Replace tool window displayed in order to process searches appropriately.

创建具有 FixedToolWindow 样式的窗体时,通常需要使用此属性。You will often wish to use this property when creating a form with the FixedToolWindow style. 设置 FixedToolWindow 样式不会单独保证窗口不会显示在任务栏中。Setting the FixedToolWindow style does not alone guarantee that a window will not appear in the taskbar.

适用于