RadToolTip
RadToolTip is a class derived from the standard ToolTip class in the System.Windows.Forms namespace. The need of a derived class arisen from the fact that the ToolTips needs a Control in order to be shown. RadToolTip encapsulates all that functionality inside of it, which makes it very flexible, requiring only the most basic parameters in order to be shown (only the text is required).
Usage
RadToolTip has a Show method with 6 overloads. The base class also has a Show method, you can tell them apart by the fact that RadToolTip does not require an IWin32Window instance. The first example shows how you can create the tooltip. Below it are all overloads coming from RadToolTip:
RadToolTip toolTip = new RadToolTip();
Dim toolTip As New RadToolTip()
- Shows a RadToolTip with the specified text on the position of the mouse with the default duration.
toolTip.Show("Tooltip text");
toolTip.Show("Tooltip text")
- Shows a RadToolTip with the specified text on the position of the mouse and with the specified duration.
toolTip.Show("Tooltip text", 2000);
toolTip.Show("Tooltip text", 2000)
- Shows a RadToolTip with the specified text on the specified position relative to the screen coordinates and with the default duration.
toolTip.Show("Tooltip text", Cursor.Position);
toolTip.Show("Tooltip text", Windows.Forms.Cursor.Position)
- Shows a RadToolTip with the specified text on the specified X and Y coordinates relative to the screen coordinates and with the default duration.
toolTip.Show("Tooltip text", 500, 500);
toolTip.Show("Tooltip text", 500, 500)
- Shows a RadToolTip with the specified text on the specified X and Y coordinates relative to the screen coordinates and with the specified duration.
toolTip.Show("Tooltip text", 500, 500, 2000);
toolTip.Show("Tooltip text", 500, 500, 2000)
- Shows a RadToolTip with the specified text on the specified position relative to the screen coordinates and with the specified duration.
toolTip.Show("Tooltip text", new Point(500,500), 2000);
toolTip.Show("Tooltip text", New Point(500, 500), 2000)
You can also hide an active ToolTip at any time using the Hide method. This method accepts no arguments, the base Hide method accepts an IWin32Window instance.
Example: Show a RadToolTip on a RadForm.
Create a new RadForm and in the code behind subscribe to its Click event. Replace the automatically generated event handler code with the following:
void RadToolTipExample_Click(object sender, EventArgs e)
{
RadToolTip newToolTip = new RadToolTip();
newToolTip.Show("A tooltip which appears at mouse position", 2000);
}
Private Sub RadToolTipExample_Click(sender As Object, e As EventArgs)
Dim newToolTip As New RadToolTip()
newToolTip.Show("A tooltip which appears at mouse position", 2000)
End Sub
Now, every time you click on the form you should see a ToolTip which will hide after 2 seconds.
RadToolTip is a derivative of MS Tooltip. In order to customize its style, you can handle the Draw event. Additional information is available here: ToolTip.Draw.