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

Get position by text index

Thread ID:

Created:

Updated:

Platform:

Replies:

109950 Jul 12,2013 08:24 AM UTC Jul 23,2013 05:10 PM UTC WinForms 7
loading
Tags: EditControl
Alexander Ivanov
Asked On July 12, 2013 08:24 AM UTC

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

Chandran R [Syncfusion]
Replied On 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

Alexander Ivanov
Replied On July 16, 2013 08:07 AM UTC

Please see sample where ConvertOffsetToVirtualPosition returns wrong value.

EditControlGetPosition_1676522a.zip

Chandran R [Syncfusion]
Replied On 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

Alexander Ivanov
Replied On 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!!!

Chandran R [Syncfusion]
Replied On 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

Alexander Ivanov
Replied On 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


Chandran R [Syncfusion]
Replied On 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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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

;