Category / Section
How to get the ToolTipInfo associated with a component or a control?
1 min read
You can retrieve the ToolTipInfo for any control with the GetToolTip method of the SuperToolTip. When the ToolTip property changes dynamically in an application, you can use this method to get the information exhibited at any point depending on the state of the application.
The following code example demonstrates the same.
C#
private void buttonAdv1_Click(object sender, EventArgs e) { // Gets the Tooltip text of the TextBoxExt. MessageBox.Show(this.superToolTip1.GetToolTip(this.textBoxExt1).Body.Text.ToString()); }
VB
Private Sub buttonAdv1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonAdv1.Click 'Gets the Tooltip text of the TextBoxExt. MessageBox.Show(Me.superToolTip1.GetToolTip(Me.textBoxExt1).Body.Text.ToString()) End Sub
In order to change the information that the control displays, use the SetToolTip method.
C#
//Initializes the ToolTipInfo. Syncfusion.Windows.Forms.Tools.ToolTipInfo toolTipInfo = new Syncfusion.Windows.Forms.Tools.ToolTipInfo(); // Specifies the text for the SuperToolTip. toolTipInfo.Header.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); toolTipInfo.Header.Text = "ToolTip added from code"; toolTipInfo.Body.Text = "Create a ToolTipInfo and assign \r\n to the control through SetToolTip"; // Sets the SuperToolTo TextBoxExt. this.superToolTip1.SetToolTip(this.textBoxExt1, toolTipInfo);
VB
'Initializes the ToolTipInfo. Dim toolTipInfo As New Syncfusion.Windows.Forms.Tools.ToolTipInfo() 'Specifies the text for the SuperToolTip. toolTipInfo.Header.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (CByte(0))) toolTipInfo.Header.Text = "ToolTip added from code" toolTipInfo.Body.Text = "Create a ToolTipInfo and assign " & Constants.vbCrLf & " to the control through SetToolTip" 'Sets the SuperToolTo TextBoxExt. Me.superToolTip1.SetToolTip(Me.textBoxExt1, toolTipInfo)
Figure 1: SuperToolTip is shown in the TextBoxExt
Sample Links: