19

I have a tooltip that is appearing on mouse hover on an image:

ToolTip tt = new ToolTip();
protected virtual void pictureBox_MouseHover(object sender, EventArgs e)
{
 tt.InitialDelay = 0;
 tt.SetToolTip(this.pictureBox, "Click 'LIVE ...");
}

My problem is that my text is rather long, and the tooltip disappears too fast. How can I get the tool tip to be displayed for longer?

JYelton
36.6k28 gold badges140 silver badges196 bronze badges
asked Nov 22, 2011 at 11:09

6 Answers 6

21

(削除) Set the AutoPopDelay property to be something higher - it defaults to 5000 (5 seconds) (削除ここまで)

Update: My mistake:

The maximum time you can delay a popup is 5000 milliseconds. For longer durations, use the Show method to control the exact moment when the ToolTip is displayed.

So you can't get the tool tip to be displayed for longer than 5 seconds using this method - instead you need to use the Show to explicitly show the tool tip when the user hovers over the picturebox. Just replace your call to SetToolTip with one to Show in your MouseHover event handler:

ToolTip tt = new ToolTip();
protected virtual void pictureBox_MouseHover(object sender, EventArgs e)
{
 tt.Show("Click 'LIVE ...", this.pictureBox, 10000);
}
answered Nov 22, 2011 at 11:11
Sign up to request clarification or add additional context in comments.

5 Comments

Thought about the same one. Or just to try set ShowAlways to true as workaround.
+1 good straight answer and for listing what the default value is.
@Justin - Turns out, despite the documentation, there's nothing stopping you from setting a longer delay, and it does work. I just set it to 20,000 milliseconds and it stayed up for that long. [Using .NET 3.5] A StackOverflow user by the name of "Panny" found that the max delay one can set is 32,767 milliseconds, which is due to 16-bit signed int problems and such and such.
@ManEatingCheese: Can't believe it - you're right. Setting AutoPopDelay to 32767 does indeed hold the message for almost 33 seconds. Create an answer out of it.
@ManEatingCheese Wow. Thanks for that. Why would they use a 16-bit int for that? That's silly...
11

Unlike the answer described by Justin, I was not able to get the ToolTip to display for longer than the 5 seconds using the show method.

One of the other hangups I was having was the AutomaticDelay property. Long story short - if you want custom AutoPopDelay do not set AutomaticDelay.

Setting this property will automatically set... see MSDN:

AutoPopDelay = 10 x AutomaticDelay

InitialDelay = AutomaticDelay

ReshowDelay = (0.2) x AutomaticDelay

Here's code that worked for me:

ToolTip tt = new ToolTip();
private void someObjectName_MouseHover(object sender, EventArgs e) {
 tt = new ToolTip
 {
 AutoPopDelay = 15000, // Warning! MSDN states this is Int32, but anything over 32767 will fail.
 ShowAlways = true,
 ToolTipTitle = "Symbolic Name",
 InitialDelay = 200,
 ReshowDelay = 200,
 UseAnimation = true
 };
 tt.SetToolTip(this.someObjectName, "This is a long message");
}

Bonus:

private void someObjectName_MouseLeave(object sender, EventArgs e)
 {
 tt.Active = false;
 }
johnthagen
9,3798 gold badges44 silver badges49 bronze badges
answered Sep 3, 2015 at 15:18

1 Comment

This solution worked better for me than @Justin's solution. I create my ToolTip for a large number of elements in the code. To do this, I use the "MouseEnter" event to trigger the ToolTip display for that element. Justin's solution results in me sometimes getting multiple ToolTip popups generated for slight mouse movements over a control. Perhaps there is a solution for this too. The solution from jetsquared works best for me in this case.
9

Set the value of AutoPopDelayproperty

 tt.AutoPopDelay = 10000;
johnthagen
9,3798 gold badges44 silver badges49 bronze badges
answered Nov 22, 2011 at 11:15

Comments

2

ToolTip.Show(text, [control], time in milliseconds) is what you need i think

This will let you display your long text for a specific number of milliseconds. Also if you text is too long then you could inert NewLine in between the text so that its wrapped up and not shown as a long tooltip spanning across the form

answered Nov 22, 2011 at 11:16

Comments

1

I've found the following steps work for me:

Set the to 1/10 of your desired .

Then you can adjust your and your afterwards.

MSDN Link

answered Jul 20, 2017 at 15:17

Comments

0

Doesn't seem to be mentioned. Setting ToolTipService.ShowDuration="20000" on the parent works for me. MSDN doesn't say but it's in milliseconds.

answered Feb 18, 2022 at 12:58

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.