Display tips in a status bar instead of a tooltip in C#

[tooltip]

A tooltip provides information when a user needs it but remains 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 that 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 tips message in a status label. When focus moves to a TextBox or the mouse moves over a button, you can display a tip 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 tips stored in their Tag properties. The program uses the following code to display and remove the tips when the mouse enters or leaves a button.

// Set the button's status tip.
private void btn_MouseEnter(object sender, EventArgs e)
{
    ToolStripButton btn = sender as ToolStripButton;
    lblStatusTip.Text = btn.Tag.ToString();
}

// Remove the button's status tip.
private void btn_MouseLeave(object sender, EventArgs e)
{
    lblStatusTip.Text = "";
}

All of the example’s toolstrip buttons share these two event handlers. When the mouse moves over a button, the btn_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.


Download Example   Follow me on Twitter   RSS feed   Donate




This entry was posted in controls, tips, user interface and tagged , , , , , , , , , , , , . Bookmark the permalink.

3 Responses to Display tips in a status bar instead of a tooltip in C#

  1. Stanislav says:

    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.

  2. Axel says:

    Thank you for this code 🙂

  3. Mariano says:

    Ron, you are the best. Congratulations!!!

Leave a Reply

Your email address will not be published. Required fields are marked *