Windows Forms ToolTip will not re-appear after first use

后端 未结 9 1337
借酒劲吻你
借酒劲吻你 2020-12-03 13:42

I have a Windows Forms C# application where I would like to use a tooltip on one of the text boxes. I initialize the tool-tip in the constructor of the Form class, and it wo

9条回答
  •  情深已故
    2020-12-03 14:03

    In my case after setting the tooltip text with the SetToolTip method, I used the Show overload with duration parameter, i.e.

    toolTip.Show(text, textEdit, 1000);
    

    After that tooltip did not reappear on mouse hover, and resetting tooltip.Active didn't work..

    A workaround that worked for me was to use Show overload without the duration, and hide it manually afterwards:

    toolTip.Show(text, textEdit);
    new Task(() =>
    {
        Thread.Sleep(750);
        textEdit.Invoke(new Action(() => toolTip.Hide(textEdit)));
    }).Start();
    

    With this code I have the desired behaviour, i.e.

    1. The tooltip is shown at once for 750 millisec. after the tooltip text has changed
    2. The tooltip does appear for the specified time when the mouse is over the control

提交回复
热议问题