How do I make a tooltip point at a specific label

2020-03-24 05:37发布

问题:

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 :)