Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

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

.net - Display a tooltip over a button using Windows Forms

How can I display a tooltip over a button using Windows Forms?

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

The ToolTip is a single WinForms control that handles displaying tool tips for multiple elements on a single form.

Say your button is called MyButton.

  1. Add a ToolTip control (under Common Controls in the Windows Forms toolbox) to your form.
  2. Give it a name - say MyToolTip
  3. Set the "Tooltip on MyToolTip" property of MyButton (under Misc in the button property grid) to the text that should appear when you hover over it.

The tooltip will automatically appear when the cursor hovers over the button, but if you need to display it programmatically, call

MyToolTip.Show("Tooltip text goes here", MyButton);

in your code to show the tooltip, and

MyToolTip.Hide(MyButton);

to make it disappear again.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...