ToolStripItem.ToolTipText 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置作为控件的 ToolTip 显示的文本。
public:
property System::String ^ ToolTipText { System::String ^ get(); void set(System::String ^ value); };
public string ToolTipText { get; set; }
public string? ToolTipText { get; set; }
member this.ToolTipText : string with get, set
Public Property ToolTipText As String
属性值
一个表示工具提示文本的字符串。
示例
下面的代码示例演示如何为 ToolStripItem设置 Image、 ImageScaling和 ImageTransparentColor 。 此外,它还演示如何设置和显示项的自定义工具提示。
ToolStripButton^ imageButton;
void InitializeImageButtonWithToolTip()
{
// Construct the button and set the image-related properties.
imageButton = gcnew ToolStripButton;
imageButton->Image =
gcnew Bitmap(Timer::typeid,"Timer.bmp");
imageButton->ImageScaling =
ToolStripItemImageScaling::SizeToFit;
// Set the background color of the image to be transparent.
imageButton->ImageTransparentColor =
Color::FromArgb(0, 255, 0);
// Show ToolTip text, set custom ToolTip text, and turn
// off the automatic ToolTips.
toolStrip1->ShowItemToolTips = true;
imageButton->ToolTipText = "Click for the current time";
imageButton->AutoToolTip = false;
// Add the button to the ToolStrip.
toolStrip1->Items->Add(imageButton);
}
// internal:
internal ToolStripButton imageButton;
private void InitializeImageButtonWithToolTip()
{
// Construct the button and set the image-related properties.
imageButton = new ToolStripButton();
imageButton.Image = new Bitmap(typeof(Timer), "Timer.bmp");
imageButton.ImageScaling = ToolStripItemImageScaling.SizeToFit;
// Set the background color of the image to be transparent.
imageButton.ImageTransparentColor = Color.FromArgb(0, 255, 0);
// Show ToolTip text, set custom ToolTip text, and turn
// off the automatic ToolTips.
toolStrip1.ShowItemToolTips = true;
imageButton.ToolTipText = "Click for the current time";
imageButton.AutoToolTip = false;
// Add the button to the ToolStrip.
toolStrip1.Items.Add(imageButton);
}
Friend WithEvents imageButton As ToolStripButton
Private Sub InitializeImageButtonWithToolTip()
' Construct the button and set the image-related properties.
imageButton = New ToolStripButton()
imageButton.Image = New Bitmap(GetType(Timer), "Timer.bmp")
imageButton.ImageScaling = ToolStripItemImageScaling.SizeToFit
' Set the background color of the image to be transparent.
imageButton.ImageTransparentColor = Color.FromArgb(0, 255, 0)
' Show ToolTip text, set custom ToolTip text, and turn
' off the automatic ToolTips.
toolStrip1.ShowItemToolTips = True
imageButton.ToolTipText = "Click for the current time"
imageButton.AutoToolTip = False
' Add the button to the ToolStrip.
toolStrip1.Items.Add(imageButton)
End Sub
注解
ToolTipText仅当 设置为 true
时ShowItemToolTips有效。 如果 AutoToolTip 设置为 ,则Text项的 属性用作 ToolTipTexttrue
。