BLOG.CSHARPHELPER.COM: Display tips in a status bar instead of a tooltip in C#
Display tips in a status bar instead of a tooltip in C#
Tooltips are meant to provide information when a user needs it but remain unobtrusive when the user doesn't need the information. For example, normally you can chug through a form filling in fields such as Name, Street, City, and State without any problem. However, if you get confused when you reach the "Oh hai!" field, you can hover the mouse over it to see a tooltip explaining what you should put in the field. Tooltips do such a good job of providing unobtrusive hints that they have been around virtually unchanged for decades.
Another method for providing hints even less obtrusively is to display a hint message in a status label. When focus moves to a TextBox or the mouse moves over a button, you can display a hint in the status label. Experienced users can easily ignore that message but it's instantly there for anyone who is confused.
In this example, the toolstrip buttons have hint text stored in their Tag properties. The program uses the following code to display and remove the hint when the mouse enters or leaves a button.
// Set the button's status tip.
private void btnNew_MouseEnter(object sender, EventArgs e)
{
ToolStripButton btn = sender as ToolStripButton;
lblStatusTip.Text = btn.Tag.ToString();
}
// Remove the button's status tip.
private void btnNew_MouseLeave(object sender, EventArgs e)
{
lblStatusTip.Text = "";
}
All of the buttons share these two event handlers. When the mouse moves over a button, the btnNew_MouseEnter event handler fires. It converts the sender parameter into the TooStripButton that raised the event. It then displays that button's Tag value in the status strip label lblStatusTip.
When the mouse leaves a button, the btnNew_MouseLeave event handler clears the text in lblStatusTip.
I use the same events to show tips in the status bar, but I use the AccessibleDescription property of the control to store the help string to keer free the Tag property. Reply to this
Hi, Rod.
It is good idea.
I use the same events to show tips in the status bar, but I use the AccessibleDescription property of the control to store the help string to keer free the Tag property.
Reply to this