0

I'm trying to add a tooltip to an OvalShape (Microsoft.VisualBasic.PowerPacks.OvalShape). Since its not a Control, I can't use the simple SetToolTip() method in the ToolTip class. How might I go about showing a ToolTip on an OvalShape? I don't absolutely have to use the ToolTip class if anyone has any better ideas. I'd also like to keep the OvalShape, unless anyone has a better solution that can give me inheritence from Control while keeping a nice circular shape.

Chad La Guardia
  • 5,088
  • 4
  • 24
  • 35

1 Answers1

3

You'll have to take advantage of the MouseHover event you can get out of the control. This worked well enough:

    bool hoverSeen = false;

    private void ovalShape1_MouseHover(object sender, EventArgs e) {
        if (!hoverSeen) {
            hoverSeen = true;
            // Todo, fix position
            Point pos = ovalShape1.Parent.PointToClient(Cursor.Position);
            toolTip1.Show("On oval", ovalShape1.Parent, pos);
        }
    }

    private void ovalShape1_MouseLeave(object sender, EventArgs e) {
        if (hoverSeen) toolTip1.Hide(ovalShape1.Parent);
        hoverSeen = false;
    }
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536