ToolTip.ShowAlways 属性

获取或设置一个值,该值指示是否显示工具提示窗口,甚至是在其父控件不活动的时候。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Property ShowAlways As Boolean
用法
Dim instance As ToolTip
Dim value As Boolean

value = instance.ShowAlways

instance.ShowAlways = value
public bool ShowAlways { get; set; }
public:
property bool ShowAlways {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_ShowAlways ()

/** @property */
public void set_ShowAlways (boolean value)
public function get ShowAlways () : boolean

public function set ShowAlways (value : boolean)

属性值

如果始终显示工具提示,则为 true;否则为 false。默认为 false

备注

使用 ShowAlways 属性,甚至在 ToolTip 的容器不活动时也可以显示工具提示窗口。您可以在无模式窗口应用程序中利用此功能,使“工具提示”窗口无论在哪个无模式窗口处于活动状态时都能显示。当您希望使用 UserControl(其中包含很多显示工具提示窗口的控件)创建控件时,此功能也很有用。由于 UserControl 通常是窗体上的不活动窗口,将此属性设置为 true 会使 UserControl 内的控件在任何时间都能显示工具提示窗口。

示例

下面的代码示例创建一个 ToolTip 类的实例,并将该实例与创建它时所在的 Form 相关联。代码随后初始化延迟属性 AutoPopDelayInitialDelayReshowDelay。另外,ToolTip 类的实例将 ShowAlways 属性设置为 true,以使工具提示文本始终显示而不管窗体是否活动。最后,该示例将工具提示文本与窗体上的 ButtonCheckBox 这两个控件关联。本代码示例要求示例中定义的方法位于 Form 之内,而该窗体应包含一个名为 button1Button 控件和一个名为 checkBox1CheckBox 控件,并且要求从 Form 的构造函数中调用该方法。

' This example assumes that the Form_Load event handling method
' is connected to the Load event of the form.
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles MyBase.Load
   ' Create the ToolTip and associate with the Form container.
   Dim toolTip1 As New ToolTip()
   
   ' Set up the delays for the ToolTip.
   toolTip1.AutoPopDelay = 5000
   toolTip1.InitialDelay = 1000
   toolTip1.ReshowDelay = 500
   ' Force the ToolTip text to be displayed whether or not the form is active.
   toolTip1.ShowAlways = True
   
   ' Set up the ToolTip text for the Button and Checkbox.
   toolTip1.SetToolTip(Me.button1, "My button1")
   toolTip1.SetToolTip(Me.checkBox1, "My checkBox1")
End Sub
// This example assumes that the Form_Load event handling method
// is connected to the Load event of the form.
private void Form1_Load(object sender, System.EventArgs e)
{
   // Create the ToolTip and associate with the Form container.
   ToolTip toolTip1 = new ToolTip();

   // Set up the delays for the ToolTip.
   toolTip1.AutoPopDelay = 5000;
   toolTip1.InitialDelay = 1000;
   toolTip1.ReshowDelay = 500;
   // Force the ToolTip text to be displayed whether or not the form is active.
   toolTip1.ShowAlways = true;
      
   // Set up the ToolTip text for the Button and Checkbox.
   toolTip1.SetToolTip(this.button1, "My button1");
   toolTip1.SetToolTip(this.checkBox1, "My checkBox1");
}
// This example assumes that the Form_Load event handling method
// is connected to the Load event of the form.
void Form1_Load( Object^ sender, System::EventArgs^ e )
{
   // Create the ToolTip and associate with the Form container.
   ToolTip^ toolTip1 = gcnew ToolTip;
   
   // Set up the delays for the ToolTip.
   toolTip1->AutoPopDelay = 5000;
   toolTip1->InitialDelay = 1000;
   toolTip1->ReshowDelay = 500;
   // Force the ToolTip text to be displayed whether or not the form is active.
   toolTip1->ShowAlways = true;
   
   // Set up the ToolTip text for the Button and Checkbox.
   toolTip1->SetToolTip( this->button1, "My button1" );
   toolTip1->SetToolTip( this->checkBox1, "My checkBox1" );
}
// This example assumes that the Form_Load event handling method
// is connected to the Load event of the form.
private void Form1_Load(Object sender, System.EventArgs e)
{
    // Create the ToolTip and associate with the Form container.
    ToolTip toolTip1 = new ToolTip();
    // Set up the delays for the ToolTip.
    toolTip1.set_AutoPopDelay(5000);
    toolTip1.set_InitialDelay(1000);
    toolTip1.set_ReshowDelay(500);
    // Force the ToolTip text to be displayed whether or not the form
    // is active.
    toolTip1.set_ShowAlways(true);
    // Set up the ToolTip text for the Button and Checkbox.
    toolTip1.SetToolTip(this.button1, "My button1");
    toolTip1.SetToolTip(this.checkBox1, "My checkBox1");
} //Form1_Load

平台

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 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

ToolTip 类
ToolTip 成员
System.Windows.Forms 命名空间
UserControl
ToolTip.Active 属性
Show