How to add tooltip to user defined textbox on a winform

c#, winforms

Solution

You forgot to instantiate `myToolTip`. You need to set it to `new Tooltip()`.

Also, I don't think it's a good practice to assign the tooltip in the textbox's constructor. You could do this in `OnCreateControl()` (that you need to override).

Your code could therefore become:

protected override void OnCreateControl()
{
    base.OnCreateControl();

    var myToolTip = new System.Windows.Forms.ToolTip
    {
        AutomaticDelay = 5000,
        AutoPopDelay = 50000,
        InitialDelay = 100,
        ReshowDelay = 500
    };

    myToolTip.SetToolTip(this, this.Text);
}

Problem

I have a `uvSelfLoadingTextBox` with multiple instances on a form. I would like to load the tooltip with the `_value` property at run time. I've tried ``` public ucSelfLoadingTextBox() { Windows.Forms.ToolTip myToolTip; myToolTip.AutomaticDelay = 5000; myToolTip.AutoPopDelay = 50000; myToolTip.InitialDelay = 100; myToolTip.ReshowDelay = 500; myToolTip.SetToolTip(this, _value); ``` inside the control but that does not work. I have tried using the tooltip that is dragged onto the form ``` ucSelfLoadingLogicTextBox uc = new ucSelfLoadingLogicTextBox(); toolTipA.SetToolTip(uc,uc._value ); ``` and that does not work. What is the correct way to do this?

Original source