Category / Section
How to implement the ContextTooltip feature in WinForms SyntaxEditor (EditControl)?
1 min read
Tooltip
The ContextTooltip can be populated with additional information on the corresponding lexem by handling the EditControl's UpdateContextTooltip event. Please refer the below code snippets.
C#
private void editControl1_UpdateContextToolTip(object sender, Syncfusion.Windows.Forms.Edit.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; e.Text = "This is of type " + configLexem.Format.Name + " : " + lexem.Text; } } } } }
VB
Private Sub editControl1_UpdateContextToolTip(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.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 e.Text = "This is of type " + configLexem.Format.Name + " : " + lexem.Text End If End If End If End If End Sub
Reference link: https://help.syncfusion.com/windowsforms/syntax-editor/intellisense#configure-context-tooltip