Use tooltips in C#


To create tooltips at design time, add a ToolTip component to a form. It adds a new property to each of the other controls on the form. In this example the ToolTip component is named tipAddress so it adds a property named ToolTip on tipAddress to each control. Set that property for a control to make that control display the tooltip. Displaying and removing tooltips at run time is automatic.

To set or change tooltips at run time, call the ToolTip component’s SetToolTip method passing it the control whose tooltip you want to change and the new tooltip text. This example uses the following code to add tooltips to the buttons at runtime.

// Add tooltips to the buttons.
private void btnAddTips_Click(object sender, EventArgs e)
        "Click to add tooltips to the buttons.");
        "Click to remove tooltips from the buttons.");

To remove a tooltip, simply use SetToolTip to set the tooltip to a blank string as shown in the following code.

// Remove tooltips from the buttons.
private void btnRemoveTips_Click(object sender, EventArgs e)
    tipAddress.SetToolTip(btnAddTips, "");
    tipAddress.SetToolTip(btnRemoveTips, "");

Download Example   Follow me on Twitter   RSS feed   Donate

This entry was posted in controls and tagged , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.