Articles in this section
Category / Section

How to enable hyperlinks in EditControl?

2 mins read

You can enable hyperlinks in the EditControl by calculating the specified text positions with the following events.

  1. MouseMove
  2. MouseDown


MouseMove: Changes the cursor, when mouse hovers on the required text of the control.

MouseDown: Navigates the specified webpage, when mouse button is pressed on the required text of the control. The CurrentLineText property helps match the input text in the EditControl.


The following code example demonstrates the same.


//Initializes the hyperlink text.
private string text = "";
//Initializes the file path.
private string filePath = Path.GetDirectoryName(Application.ExecutablePath) + @"\..\..\hyper.php";
//Loads files in EditControl.
//Specifies the cursor.
private void editControl1_MouseMove(object sender, MouseEventArgs e)
    //Gets the mouse point.
    Point pointVirtual = editControl1.PointToVirtualPosition(new Point(e.X, e.Y));
    if (pointVirtual.Y > 0)
        //Gets the line.
        ILexemLine line = editControl1.GetLine(pointVirtual.Y);
        if (line != null)
            ILexem lexem = line.FindLexemByColumn(pointVirtual.X);
            if (lexem != null)
                IConfigLexem configLexem = lexem.Config as IConfigLexem;
                if (text.Contains(lexem.Text))
                    this.editControl1.Cursor = Cursors.Hand;
                    this.editControl1.Cursor = Cursors.Default;
                this.editControl1.Cursor = Cursors.Default;
//Navigates to the website.
void editControl1_MouseDown(object sender, MouseEventArgs e)
    if (this.editControl1.CurrentLineText.Contains(text) && text.Contains(this.editControl1.GetCurrentWord()))
        //Opens the hyperlink in the webpage.
        ProcessStartInfo hyperlink = new ProcessStartInfo("");



'Initializes the hyperlink text.
Private textValue As String = ""
'Initializes the file path.
Private filePath As String = Path.GetDirectoryName(Application.ExecutablePath) & "\..\..\hyper.php"
'Loads files in EditControl.
'Specifies the cursor.
Private Sub editControl1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
 'Gets the mouse point.
 Dim pointVirtual As Point = editControl1.PointToVirtualPosition(New Point(e.X, e.Y))
 If pointVirtual.Y > 0 Then
  'Gets the line.
  Dim line As ILexemLine = editControl1.GetLine(pointVirtual.Y)
  If line IsNot Nothing Then
   Dim lexem As ILexem = line.FindLexemByColumn(pointVirtual.X)
   If lexem IsNot Nothing Then
    Dim configLexem As IConfigLexem = TryCast(lexem.Config, IConfigLexem)
    If text.Contains(lexem.Text) Then
     Me.editControl1.Cursor = Cursors.Hand
     Me.editControl1.Cursor = Cursors.Default
    End If
    Me.editControl1.Cursor = Cursors.Default
   End If
  End If
 End If
End Sub
'Navigates to the website.
Private Sub editControl1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
     If Me.editControl1.CurrentLineText.Contains(textValue) AndAlso textValue.Contains(Me.editControl1.GetCurrentWord()) Then
         'Opens the hyperlink in the webpage.
          Dim hyperlink As New ProcessStartInfo("")
     End If
End Sub



PointToVirtualPosition helps to get the virtual position of the text. It also helps to converts the points in client coordinates to the virtual position in text.



EditControl shows with hyperlinks in C#

Figure 1: EditControl shows with hyperlinks in C#

EditControl shows with hyperlinks in VB

Figure 2: EditControl shows with hyperlinks in VB

Webpage loaded to browser after clicking hyperlink

Figure 3: Webpage loaded to browser after clicking the Hyperlink in EditControl

Sample Links:

C#: EditControl_HyperLink_C#

VB: EditControl_HyperLink_VB

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