Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
776 views
in Technique[技术] by (71.8m points)

winforms - C# tooltip doesn't display long enough

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...