We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I convert offset values into text range in the EditControl ?

Platform: WinForms |
Control: EditControl |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014


In other words, this article explains how to get the associated CoordinatePoint values from text offset values. You would have to convert offset values into VirtualPoints and then VirtualPoints to ParsePoints before converting them to CoordinatePoints. Please refer to the code snippets below that illustrate this.


// Starting offset converted to virtual point

Point startVirtualPoint = this.editControl1.ConvertOffsetToVirtualPosition(startOffsetValue);

// Ending offset converted to virtual point

Point endVirtualPoint = this.editControl1.ConvertOffsetToVirtualPosition(endOffsetValue);

// Converting the VirtualPoints to ParsePoints

ParsePoint startParsePoint = new ParsePoint(startVirtualPoint.Y, startVirtualPoint.X, 0);

ParsePoint endParsePoint = new ParsePoint(endVirtualPoint.Y, endVirtualPoint.X, 0);

// Creating the associated CoordinatePoints that indicate the text range

CoordinatePoint startCoordinatePoint = new CoordinatePoint(this.editControl1.Parser as ILexemParser, startParsePoint, startVirtualPoint.Y, startVirtualPoint.X, true);

CoordinatePoint endCoordinatePoint = new CoordinatePoint(this.editControl1.Parser as ILexemParser, endParsePoint, endVirtualPoint.Y, endVirtualPoint.X, true);


' Starting offset converted to virtual point

Dim startVirtualPoint As Point = Me.editControl1.ConvertOffsetToVirtualPosition(startOffsetValue)

' Ending offset converted to virtual point

Dim endVirtualPoint As Point = Me.editControl1.ConvertOffsetToVirtualPosition(endOffsetValue)

' Converting the VirtualPoints to ParsePoints

Dim startParsePoint As New ParsePoint(startVirtualPoint.Y, startVirtualPoint.X, 0)

Dim endParsePoint As New ParsePoint(endVirtualPoint.Y, endVirtualPoint.X, 0)

' Creating the associated CoordinatePoints that indicate the text range

Dim startCoordinatePoint As New CoordinatePoint(CType(Me.editControl1.Parser, ILexemParser), startParsePoint, startVirtualPoint.Y, startVirtualPoint.X, True)

Dim endCoordinatePoint As New CoordinatePoint(CType(Me.editControl1.Parser, ILexemParser), endParsePoint, endVirtualPoint.Y, endVirtualPoint.X, True)

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon