Articles in this section
Category / Section

How to selectively hide or show the Context Tooltip in WinForms SyntaxEditor (EditControl)?

2 mins read

Show the Context tooltip

The Context Tooltip can be selectively hidden or shown using the UpdateContextTooltip event. The following code shows how the Context Tooltip can be displayed only if the mouse cursor moves over a Keyword, for the rest of the text, the Context Tooltip is not displayed.

C#

private void editControl1_UpdateContextToolTip(object sender, Syncfusion.Windows.Forms.Edit.Dialogs.UpdateTooltipEventArgs e)
{
    if(e.Text == string.Empty )
    {
        Point pointVirtual = editControl1.PointToVirtualPosition( new Point( e.X, e.Y ) );
        if(pointVirtual.Y > 0 )
        {
            // Get the current line
            ILexemLine line = editControl1.GetLine( pointVirtual.Y );
            if( line != null )
            {
               // Get tokens from the current line
               ILexem lexem = line.FindLexemByColumn( pointVirtual.X );
               if( lexem != null )
               {
                   IConfigLexem configLexem = lexem.Config as IConfigLexem;
                   string formatName = configLexem.Format.Name;
                   if (formatName == "KeyWord")
                   {
                       e.Text = "This is a " + formatName + " : " + lexem.Text;
                   }
               }
            }
        }
    }
}

 

VB

Private Sub editControl1_UpdateContextToolTip(sender As Object, e As Syncfusion.Windows.Forms.Edit.Dialogs.UpdateTooltipEventArgs) Handles editControl1.UpdateContextToolTip
    If e.Text = String.Empty Then
        Dim pointVirtual As Point = editControl1.PointToVirtualPosition(New Point(e.X, e.Y))
        If pointVirtual.Y > 0 Then
           ' Get the current line
           Dim line As ILexemLine = editControl1.GetLine(pointVirtual.Y)
           If Not (line Is Nothing) Then
              ' Get tokens from the current line
              Dim lexem As ILexem = line.FindLexemByColumn(pointVirtual.X)
              If Not (lexem Is Nothing) Then
                  Dim configLexem As IConfigLexem = lexem.Config
                  Dim formatName As String = configLexem.Format.Name
                  If formatName = "KeyWord" Then
                     e.Text = "This is a " + formatName + " : " + lexem.Text
                  End If
              End If
           End If
        End If
    End If
End Sub 'editControl1_UpdateContextToolTip

Reference link: https://help.syncfusion.com/windowsforms/syntax-editor/intellisense#configure-context-tooltip

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