Question

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.

Was it helpful?

Solution

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;
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top