Category / Section
How to show the SuperToolTip through Code?
1 min read
The ToolTip can be shown through the Code by using the SetToolTip() method of the SuperToolTip control. A ToolTipInfo object has to be created.
The following code example demonstrates the same.
C#
//Initializes the ToolTipInfo.
Syncfusion.Windows.Forms.Tools.ToolTipInfo toolTipInfo = new Syncfusion.Windows.Forms.Tools.ToolTipInfo();
// Sets the back color.
toolTipInfo.BackColor = Color.Chartreuse;
// Sets the body text of the SuperToolTip.
toolTipInfo.Body.Text = "Create a ToolTipInfo and assign \r\n to the control through SetToolTip";
// Sets the header text.
toolTipInfo.Header.Text = "ToolTip added from code";
// Sets the header font.
toolTipInfo.Header.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
// Sets the header image.
toolTipInfo.Header.Image = new Bitmap("..\\..\\App.ico");
// Sets the header alignment.
toolTipInfo.Header.TextAlign = ContentAlignment.MiddleCenter;
// Sets the border color.
toolTipInfo.BorderColor = Color.FromArgb(200, 212, 53);
// Sets the SuperToolTip to the list box.
this.superToolTip1.SetToolTip(this.listBox1, toolTipInfo);
VB
'Initializes the ToolTipInfo.
Dim toolTipInfo As New Syncfusion.Windows.Forms.Tools.ToolTipInfo()
'Sets the back color.
toolTipInfo.BackColor = Color.Chartreuse
'Sets the body text of the SuperToolTip.
toolTipInfo.Body.Text = "Create a ToolTipInfo and assign " & Constants.vbCrLf & " to the control through SetToolTip"
'Sets the header text.
toolTipInfo.Header.Text = "ToolTip added from code"
'Sets the header font.
toolTipInfo.Header.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (CByte(0)))
'Sets the header image.
toolTipInfo.Header.Image = New Bitmap("..\..\App.ico")
'Sets the header alignment.
toolTipInfo.Header.TextAlign = ContentAlignment.MiddleCenter
'Sets the border color.
toolTipInfo.BorderColor = Color.FromArgb(200, 212, 53)
'Sets the SuperToolTip to the list box.
Me.superToolTip1.SetToolTip(Me.listBox1, toolTipInfo)

Figure 1: SuperToolTip assigned to ListBox
Sample Links: