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 : Nov 16th 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 ?

 

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.

C#

// 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);

C#

' 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)

Article ID: Published Date: Last Revised Date: Platform: Control:
320 04/30/2011 07/10/2014 WinForms EditControl
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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