Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create ToolTip for Custom UserControl

Tags:

c#

winforms

I need to understand how to utilize a ToolTip with a custom UserControl. Just creating the ToolTip on a form and assigning the specific control a ToolTip (via SetToolTip) obviously will not work.

What properties do I need to give the custom UserControl in order to assign ToolTip text to it? Do I need to add a ToolTip on the usercontrol form? How can I go about doing this?

Please provide a code sample or something for me to visualize.

Thank you!

like image 769
Encryption Avatar asked Dec 20 '11 20:12

Encryption


1 Answers

Put a ToolTip on your UserControl (use the designer, just like you would put one on a form), and add a public property to your UserControl like:

    public string TextBoxHint
    {
        get 
        { 
            return toolTip1.GetToolTip(textBox1); 
        }
        set
        {
            toolTip1.SetToolTip(textBox1, value);                
        }
    }
like image 109
Igby Largeman Avatar answered Sep 20 '22 13:09

Igby Largeman