.NET Array Dictionary List String 2D Async DataTable Dates DateTime Enum File For Foreach Format IEnumerable If IndexOf Lambda Parse Path Process Property Regex Replace Row Sort Split Static StringBuilder Substring Switch Tuple WindowToolTip makes interfaces more intuitive. We add the ToolTip control to a Windows Forms application, which provides useful contextual hints to the client. We use Visual Studio to easily add, modify, and present ToolTips.
Add. 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. 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 will appear here. Your ToolTip control will as well. Overview. 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.
Instead:We can use the designer to create all the ToolTips. This may be easier to maintain.
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. Text. 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. Please 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. 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. Guidelines. We check the guidelines for writing ToolTip text in your Windows Forms application. If you have a smaller development shop, programmers may need to write 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.
Note:In the first screenshot on this article, the ToolTip uses the short declarative sentence "This is the tooltip you added."
Also:It might have been better for the ToolTip to have the word "tooltip" capitalized with Pascal case.
Methods. 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.
Tip:The Show method forces the tip to be displayed. The Hide method forces a ToolTip to disappear.
And:The Get and SetToolTip methods let you assign tooltips programmatically to controls.
Properties. 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.
Tip:You can change the Active property, the color properties, the icon and title properties and 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, 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:AutomaticDelay 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.
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.
ToolTipIcon. 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.
Tip:You should carefully reference Microsoft's guidelines (MSDN) for user experience.Notifications: MSDN
Animation. 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.
IsBalloon. You can specify a balloon tip with the IsBalloon property. My experience is that balloons are poorly implemented and challenging to get exactly right. The balloon positioning is unpredictable when attached to controls such as TextBox.
Summary. 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.