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. Image for the cookie policy date
close icon

Get position by text index

Hi!
I find string in EditControl1.Text by IndexOf method.
How I can get Column and Line or position?
ConvertOffsetToVirtualPosition method returns wrong value.

7 Replies

CR Chandran R Syncfusion Team July 15, 2013 05:39 PM UTC

Hi  Alexander,

 

Thank you for using Syncfusion products.

 

Query

Response

ConvertOffsetToVirtualPosition method returns wrong value

I would like to inform that , the ConvertOffsetToVirtualPosition function returns the correct value and I have attached the sample as per your requirement. please make use of the sample from the attachments.

How I can get Column and Line or position?

You can get the current column value by using the following code snippets.

 

 Code snippet:

MessageBox.Show(this.editControl1.CurrentLine.ToString());

 

 

Please let us know if you have any concerns.

 

Regards

 

Chandran R



EditControlGetPosition_ca34bf7e.zip


AI Alexander Ivanov July 16, 2013 08:07 AM UTC

Please see sample where ConvertOffsetToVirtualPosition returns wrong value.

EditControlGetPosition_1676522a.zip


CR Chandran R Syncfusion Team July 16, 2013 04:40 PM UTC

Hi  Alexander,

Thanks for the update.

 

Query

Response

Get position

I would like to inform that , I have attached the sample for getting the position. You can get the position with mouse position.

Please make use of the sample from the attachments.

 

Note:

Displaying incorrect position due to incorrect index  value.

 

 

Please let us know if you have any concerns.

 

Regards,

 

Chandran R



Editcontrolposition_bfb0f497.zip


AI Alexander Ivanov July 16, 2013 06:53 PM UTC

I have't mouse position. I search in text by IndexOf, I parse text, I use regular expressions. And I need get Position (column, line) of EditControl by text index!!!


CR Chandran R Syncfusion Team July 17, 2013 03:18 PM UTC

Hi  Alexander,

Thanks for the update.

Query

Response

How I can get Column and Line or position?

You can find the string by using the method Findtext  , after finding the string we can get the position by using the current position.

Please make use of the sample from the attachments.

 

Please let us know if you have any concerns.

 

Regards,

 

Chandran R



EditControlGetPosition_74f93f15.zip


AI Alexander Ivanov July 18, 2013 03:08 PM UTC

I find solution:

Dim index As Int32 = RTB.GetTextWithNewLineStyle().IndexOf("Private Sub ")

Dim vp As Point = RTB.ConvertOffsetToVirtualPosition(index)

Dim Offset As Int32 = RTB.ConvertVirtualPositionToOffset(vp) / 2 - 1 'for Unicode encoding

Dim Offset As Int32 = RTB.ConvertVirtualPositionToOffset(vp) 'for ASCII



CR Chandran R Syncfusion Team July 23, 2013 05:10 PM UTC

Hi Alexander,

Thanks for the update.

We are glad that you have found solution for your query and kindly let us know if you have any other query in this category.

Regards,

Chandran R


Loader.
Live Chat Icon For mobile
Up arrow icon