ToolTip makes interfaces more intuitive. We add the ToolTip control to a Windows Forms application, which provides useful contextual hints to the client. We use the Visual Studio designer to easily add ToolTips.
First, to add a ToolTip control to your Windows Forms application, you need to open the ToolBox panel in Visual Studio's designer. Then, open the "All Windows Forms" pane and find ToolTip. Double-click the ToolTip icon in the panel.
Looking at the Designer tray. In the Visual Studio designer, there is a gray tray near the bottom of your Window. This area shows controls that do not appear inside your Windows Forms. Some dialog boxes you add will appear here. Your ToolTip control will appear here as well. Please see the image below.
Here we look at an overview of the ToolTip control in Windows Forms. First, many examples on ToolTips will show you the C# code to add them directly. However, this isn't necessary in many programs and will just make your code more complicated. Instead, we can use the designer to create all the ToolTips.
How you can assign ToolTips. In your Designer view in Visual Studio, each control, such as Buttons and TextBoxes, will acquire a "ToolTip on toolTip1" property when you add a toolTip1 to your designer view. You can access this property in the Properties pane to set the tool tips.
Here we add a ToolTip to a Button control in Windows Forms. Let's add a Button named button1 to your Windows Forms window in the Designer.Button
Setting the property. Click on the button1 so it is focused. It will be surrounded by the resizing boxes. Now open the Properties pane and make sure the Properties icon near the top is selected. Scroll down to the ToolTip on toolTip1 row, and add some text to it.
Next, you can run your Windows Forms application and hover your mouse over the Button control. You will see that you now have a tool tip on the button. You can apply this technique to most controls and it is ideal for rapid application development. Please see the top image.
We check the guidelines for writing ToolTip text in your Windows Forms application. If you have a smaller development shop, the programmers may need to write much of the text. The "User Interface Text" guideline document at MSDN is used next.User Interface Text: MSDN
Infotips use sentence case and ending punctuation. In other words, you want your ToolTip (also called Infotips) to be a short, grammatical, and declarative sentence. Use an ending period. Normally, you should avoid question marks or exclamation marks.
Note:In the first screenshot on this article, the ToolTip uses the short declarative sentence "This is the tooltip you added." This is an example of the correct way to phrase the ToolTips.
Also:You should be consistent in capitalization. It might have been better for the ToolTip to have the word "tooltip" capitalized with Pascal case.
It is possible and sometimes useful to write ToolTip code in C# code. If you can avoid this, however, it is best. Often, ToolTips that use IsBalloon will need to have custom C# or VB.NET code.
Important methods. The most important methods on ToolTip controls you can use in C# or VB.NET are the Show method, the Hide method, the SetToolTip method, and the GetToolTip method. First, the Show method forces the tip to be displayed. This is usually a bad design decision.
The other ToolTip methods. The Hide method forces a ToolTip to disappear. The Get and SetToolTip methods let you assign tooltips programmatically to controls. Avoiding these methods will result in easier code to maintain and debug. But some programs may have a requirement for these methods.
Here are my notes on the properties available in the Visual Studio designer for the ToolTip control in Windows Forms. I have done work with ToolTips in C# code, but this is not usually necessary. The properties that are useful to change include the Active property, the color properties, the icon and title properties, and sometimes the balloon property.Property
Active property. This allows you to specify if the ToolTip is available to be opened or shown. When you set the Active property in your C# source code, the ToolTip is not immediately shown. Instead, it is enabled to be shown later.
AutomaticDelay property. This property allows you to specify the number of milliseconds after the user hovers over the ToolTip before it is shown. This isn't worth changing in most programs.
But:It could be useful in certain programs where accessibility is a requirement.
AutoPopDelay:This property lets you specify how long in milliseconds a ToolTip will remain on the screen if the mouse is frozen. This property isn't often useful. I recommend you leave it set to the default of 5 seconds.
BackColor and ForeColor property. You can set the background and foreground of your ToolTip. It is usually best to avoid changing these. If you have a serious alert to display, a ToolTip isn't the right control.
However:In some cases a different shade of light blue or pink can really enhance the impression of the ToolTip.
InitialDelay and ReshowDelay. These attributes let you specify the exact delays in milliseconds. Normally, these are best left with their default values, as the defaults are sensible.
Note:Unless you have a specific reason for changing these, you are probably going to hurt the usability of your program more than help it.
StripAmpersands property. Often, globalization is implemented with ampersands. This property lets you specify if your strings contain ampersands that need to be removed. If your program does not use ampersands for globalization, using False is OK.
ToolTipIcon and ToolTipTitle allow you specify an image to display on the tooltip, and a title to display. The title will be displayed in bold font at the beginning of the tooltip, on a new line. Using titles on tooltips is non-standard in most cases, so is best avoided.
Tip:As always, you should carefully reference Microsoft's guidelines for user experience.Notifications: MSDN
The UseAnimation and UseFading properties let you specify the visual effects used on your tooltips. Windows XP and Windows Vista allow users to specify animation preferences in the Control Panel.
Tip:It is best to leave these to their default, so the user's preferences are always applied.
You can specify a balloon tip with the IsBalloon property. My experience is that balloons are poorly implemented and challenging, or impossible, to get exactly right.
Note:The balloon positioning is unpredictable when attached to controls such as TextBox, and can end up causing you a big headache.
Here we looked at how you can use ToolTips in your Windows Forms programs. Ideally, you can implement your tips entirely in the Designer, keeping all the code out of your private implementation.
Review:We looked at an example and then touched on some properties and methods of ToolTip controls.