0

I have a picturebox with an associated tooltip that I want to show when the picturebox is clicked, but not when the mouse is hovered over it. I tried creating an empty MouseHover event for the picturebox, but the tooltip is still displayed:

    private void pictureBox3_MouseHover(object sender, EventArgs e)
    {

    }

    private void pictureBox3_Click(object sender, EventArgs e)
    {
        int durationMilliseconds = 30000;
        toolTip1.Show(toolTip1.GetToolTip(pictureBox3), pictureBox3, durationMilliseconds);
    }

What can I do so that the tooltip is not displayed on MouseHover?

1
  • Events can have multiple methods tied to them. Try adding e.Handled =true to the hover event. That way the event is marked as handled and subsequent methods on that event are not called. Commented May 31, 2017 at 8:54

1 Answer 1

3

Don't set a tooltip for pictureBox3 (remove it). Just show one:

// On class scope to have access from MouseEnter
ToolTip tt = new ToolTip();

private void pictureBox3_Click(object sender, EventArgs e)
{
    int durationMilliseconds = 30000;        
    tt.IsBalloon = true;
    tt.InitialDelay = 0;
    tt.Show("tooltip text", pictureBox3, durationMilliseconds);
}

To prevent the tooltip to be set permantly add an event handler to the picturebox for MouseEnter:

private void pictureBox3_MouseEnter(object sender, EventArgs e)
{
     tt.RemoveAll();
}
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks! After a click the hover event is active again though. (I have removed the original tooltip)
I have added a way to prevent this
Thanks again for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.