Articles in this section
Category / Section

How to underline text between two given offsets in the WinForms SyntaxEditor (EditControl)?

1 min read


The SyntaxEditor (EditControl) allows you to underline any desired text in its contents. Underlines can be of different styles, colors, and weights with each of them being used to convey a different meaning. Please refer the below code snippets.


// Starting offset converted to virtual point
Point pt1 = this.editControl1.ConvertOffsetToVirtualPosition(inputDialog.Point1);
// Ending offset converted to virtual point
Point pt2 = this.editControl1.ConvertOffsetToVirtualPosition(inputDialog.Point2);
this.editControl1.SetSelection(pt1.X, pt1.Y, pt2.X, pt2.Y);
ISnippetFormat format = editControl1.RegisterUnderlineFormat(Color.Red, UnderlineStyle.Wave, UnderlineWeight.Thick);
this.editControl1.SetUnderline (this.editControl1.Selection.Top, this.editControl1.Selection.Bottom, format);



' Starting offset converted to virtual point
Dim pt1 As Point = Me.editControl1.ConvertOffsetToVirtualPosition(inputDialog.Point1)
' Ending offset converted to virtual point
Dim pt2 As Point = Me.editControl1.ConvertOffsetToVirtualPosition(inputDialog.Point2)
Me.editControl1.SetSelection(pt1.X, pt1.Y, pt2.X, pt2.Y)
Dim format As ISnippetFormat = editControl1.RegisterUnderlineFormat(Color.Red,UnderlineStyle.Wave,UnderlineWeight.Thick)
Me.editControl1.SetUnderline (Me.editControl1.Selection.Top, Me.editControl1.Selection.Bottom, format)


Reference link:

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