Articles in this section
Category / Section

How to display the SuperToolTip for disabled controls?

2 mins read

You can display the SuperToolTip for disabled controls when mouse over on it. For the disabled controls, mouse pointer notification and events related to that are not triggered. This requirement can be achieved by handling the parent form's MouseMove event and the GetChildAtPoint function.

 

Purpose of GetChildAtPoint:

This function retrieves the child control that is located at the specified coordinates. So, when the cursor points over a specified control, the SuperToolTip can be displayed.

 

C#

bool IsShown = false;
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
    Control ctrl = this.GetChildAtPoint(e.Location);
    if (ctrl != null)
    {
        if (ctrl == this.buttonAdv1 && !IsShown)
        {
            //Initializes the ToolTipInfo
            ToolTipInfo tooltip = new ToolTipInfo();
            tooltip.Body.Text = "SuperToolTip";
            //Sets the SuperToolTip
            this.superToolTip1.SetToolTip(this.buttonAdv1, tooltip);
            System.Drawing.Point pt1 = new System.Drawing.Point(ctrl.Location.X+20, ctrl.Location.Y+30);
            //Shows the SuperToolTip in the specified location
            this.superToolTip1.Show(tooltip, this.PointToScreen(pt1), 1000);
            IsShown = true;
        }
    }
    else
    {
        this.superToolTip1.Hide();
        IsShown = false;
    }
}

 

VB

Private IsShown As Boolean = False
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove
    Dim ctrl As Control = Me.GetChildAtPoint(e.Location)
    If ctrl IsNot Nothing Then
      If ctrl Is Me.buttonAdv1 AndAlso (Not IsShown) Then
         'Initializes the ToolTipInfo
         Dim tooltip As New ToolTipInfo()
         tooltip.Body.Text = "SuperToolTip"
         'Sets the SuperToolTip
         Me.superToolTip1.SetToolTip(Me.buttonAdv1, tooltip)
         Dim pt1 As New System.Drawing.Point(ctrl.Location.X+20, ctrl.Location.Y+30)
          'Shows the SuperToolTip in the specified location
          Me.superToolTip1.Show(tooltip, Me.PointToScreen(pt1), 1000)
          IsShown = True
      End If
      Else
          Me.superToolTip1.Hide()
          IsShown = False
      End If
End Sub

Output:

Show supertooltip on disabled controls

 

Sample: View sample in GitHub.

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied