How do I make a tooltip point at a specific label in C#?

雨燕双飞 提交于 2019-12-01 06:02:14

问题


In my application I want to use a tooltip to point at a label to get the users attention:

toolTip.IsBalloon = true;
toolTip.Show("message", label1);

The problem is that the balloon isn't pointing at the specified label. What should I do?


回答1:


This is a known bug.

Try calling it twice for a hack work-around:

toolTip.Show(string.Empty, label1, 0);
toolTip.Show("message", label1);



回答2:


You can do something like this.. more specific (i.e) how much time the tool tip will be displayed...

When MouseLeave

   public class MouseLeave
   {
       public void mouseLeave(Label label1, ToolTip ttpTemp)
       {
          ttpTemp.Hide(label1);
       }
  }

when mouse enter

  public class MouseOver
  {
    public void mouseOver(Label label1, ToolTip ttpTemp)
    {
                    ttpTemp.AutoPopDelay = 2000;
                    ttpTemp.InitialDelay = 1000;
                    ttpTemp.ReshowDelay = 500;
                    ttpTemp.IsBalloon = true;
                    ttpTemp.SetToolTip(label1, "Message1");
                    ttpTemp.Show("message1", label1,label1.width,label1.height/10,5000);
      }
   }



回答3:


Tooltip works with MouseHover and MouseLeft [just imagine in this way] If the mouse come over the Label, the tooltip will be displayed, when the mouse left, tooltip will dissappear.

and the code should be:

    ToolTip t = new ToolTip();
    t.IsBalloon = true;
    t.ToolTipTitle = "Title";
    t.SetToolTip(label1, "Text");

just ToolTipTitle is optional :)



来源:https://stackoverflow.com/questions/7627185/how-do-i-make-a-tooltip-point-at-a-specific-label-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!