ToolStripItem.AutoToolTip ToolStripItem.AutoToolTip ToolStripItem.AutoToolTip ToolStripItem.AutoToolTip Property

定义

获取或设置一个值,该值指示对 ToolTipText 工具提示使用 Text 属性还是 ToolStripItem 属性。Gets or sets a value indicating whether to use the Text property or the ToolTipText property for the ToolStripItem ToolTip.

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

属性值

true 表示对工具提示使用 Text 属性;否则为 falsetrue to use the Text property for the ToolTip; otherwise, false. 默认值为 trueThe default is true.

示例

下面的代码示例演示如何Image设置、 ImageScalingImageTransparentColor ToolStripItemThe following code example demonstrates how to set the Image, ImageScaling, and ImageTransparentColor for a ToolStripItem. 此外, 它还演示如何设置和显示项的自定义工具提示。In addition, it demonstrates how to set and show a custom ToolTip for the item.

    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

注解

ToolStripItem使用属性作为ToolTip内容的默认源。 TextToolStripItem uses the Text property as the default source for the ToolTip content. 设置AutoToolTipfalse ToolTip将用作内容的源。ToolTipTextSet AutoToolTip to false to use ToolTipText as the source for ToolTip content.

若要使用此属性, 还必须将ShowItemToolTips设置true为。To use this property, you must also set ShowItemToolTips to true.

适用于