A WinForm 'ToolTip is an "extender provider" Control: you'll notice that when you drag-drop one onto a Form its icon appears below the Form in the area where Components also show-up.
At design-time:
Once you add a ToolTip to your project then you'll find that when you open the Property Browser for any Control it will have a field where you can enter Text with a name like: ToolTip on toolTip1.
1. you can select (using the mouse) any number of Controls on a Form, of any Type, open the Property browser and set the selected Controls' ToolTip static text: that text will appear when the mouse is hovered over any of the Controls you selected.
At run-time:
1. initialzing ToolTip content when the Form loads:
private void Form1_Load(object sender, EventArgs e)
{
foreach (Button btn in this.Controls.OfType<Button>())
{
toolTip1.SetToolTip(btn, btn.Name);
}
}
Keep in mind that this would find all the Button on the Form surface and set their ToolTips to the Button's 'Name property; it would not find any Button inside a container Control, like a Panel (in other words, it is not a recursive function).
2. if you wish different dynamic content presented by the Tooltip depending on the Control the ToolTip is activated for:
a. usually you will have some EventHandler installed for a Control, or Controls, and in that EventHandler you will make the call the shows the ToolTip with the text you want.
b. So, say you had six Buttons on a Form, and you wired-up a MouseHover EventHandler for all six Buttons like this:
Point btnOffset = new Point(75,0);
private void SixButtons_MouseHover(object sender, EventArgs e)
{
Button hoverButton = sender as Button;
toolTip1.Show(hoverButton.Name, hoverButton, btnOffset);
}
In this case the variable 'btnOffset of Type 'Point controls where you want the 'toolTip1 to be shown relative to the upper-left corner of the Button the mouse hovers over.
Example b. is a bit "silly," because: why would want to use some kind of dynamic code to show a property that doesn't change (is static).
There are rare occasions where you may want to give different ToolTip feedback based on what the user of your application is doing, and that's when you might go to the trouble of implementing dynamic ToolTip content.