How do I write code to display tool tip for controls?
Ans: We can display a tool tip for any control placed on a form. For this, we have to add a ToolTip control to the form. As soon as we add the ToolTip control a property named ‘Tooltip on tip’ gets added to the ‘Properties’ window of all the controls placed on the form. The string entered against this property gets displayed as the tool tip when mouse is moved over the control. How come only one ToolTip control manages to display tips for all the controls for which ‘Tooltip on tip’ property is set? When we set the ‘Tooltip on tip’ property of a control, a call to the ToolTip.SetToolTip( ) method gets added in the InitializeComponent( ) method as shown below:
tip.SetToolTip ( button, “This is a Button” ) ;
The reference to the control (in this case, button) is passed to the SetToolTip( ) method along with the tool tip text. The SetToolTip( ) method associates the text with the specified control.