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.
Unfortunately, activation email could not send to your email. Please try again.

Modifying text programmatically without changing the cursor position and scroll offset

Thread ID:

Created:

Updated:

Platform:

Replies:

90140 Sep 18,2009 06:24 AM Oct 5,2009 01:08 AM Windows Forms 6
loading
Tags: EditControl
Alain Frisch
Asked On September 18, 2009 06:24 AM

Hello,

Is there is way to change the text displayed by the editor (using methods like InsertText or DeleteText) without changing the cursor position and the scroll offset of the editor?


Regards,

Alain

Nandakumar R [Syncfusion]
Replied On September 18, 2009 06:41 AM

Hi Alian,

Please refer to the below forum thread. Here is a sample that shows how you can insert or remove text.

http://www.syncfusion.com/support/forums/edit-windows/89847/test-currentline-for-text-and-relocate-to-end-of-line

Please try this sample and let me know if you have more questions. Posting a simple sample or a screen shot of what you are expecting will be fine for us to easily understand your requirements and update you for that.

Thanks for your interest in Syncfusion Essential Studio.

Regards,
Nanda

Alain Frisch
Replied On September 18, 2009 07:31 AM

Thanks for your answer. As my initial message says, I'm aware of how to insert or delete text programmatically. However, the DeleteText and InsertText functions also change the cursor position and the scroll offset. For instance, InsertText puts the cursor at the end of the inserted text. I'd like to know if there is a way to insert or delete text without changing the cursor position.

Regards,

Alain

Nandakumar R [Syncfusion]
Replied On September 22, 2009 12:16 AM

Hi Alain,

Thanks for the update. Currently there is no option to keep the current cursor position in the same place when inserting the text. But, you can achieve the same by the following way.

[C#]
private void btnCurPosition_Click(object sender, EventArgs e)
{
Point cursorPostn = this.editControl1.CurrentPosition;
this.editControl1.FindText("won");
this.editControl1.CurrentPosition = this.editControl1.Selection.Start.VirtualPoint;
this.editControl1.InsertText(this.editControl1.CurrentLine, this.editControl1.CurrentColumn - 1, @"CHA");
this.editControl1.SelectionCancel();
//Try commenting and uncommenting this to note the difference.
this.editControl1.CurrentPosition = cursorPostn;
this.editControl1.Focus();
}

Please try the sample below on the same and let me know if this helps.
http://www.syncfusion.com/uploads/redirect.aspx?file=Edit_Sample_f94b5e0a.zip&team=support


Regards,
Nanda

Nandakumar R [Syncfusion]
Replied On September 22, 2009 12:45 AM

Hi,

I regret for the posting the wrong link. Please refer to the updated link below.

http://www.syncfusion.com/uploads/redirect.aspx?file=Edit_Sample_f94b5e0a.zip&team=support

Thanks,
Nanda

Alain Frisch
Replied On October 1, 2009 09:39 AM

Thanks.

We already do something similar. In addition to saving and restoring the cursor location, we also do the same for the current scroll offset. However, this is not very satisfying and sometimes the restored scroll position is not exactly the same as before the operation. All in all, this is not very satisfying (we can see the text buffer scrolling). We'd prefer it if modifying the text programmatically with changing the cursor and scroll were a basic feature of the editor widget.


Regards,

Alain

Nandakumar R [Syncfusion]
Replied On October 5, 2009 01:08 AM

Hi Alain,

I regret for the inconvenience caused. There are some critical issues existing with the scrolling and we are clearing each of them for the Essential Studio vol.4 refresh release. The scrolling feature will be updated with this release and we are expecting this release to be available by the middle of December 2009.

Thanks for your patience.

Regards,
Nanda

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.

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.

;