Sign in to follow this  
chrisliando

[.net] How to update textBox cursor position?

Recommended Posts

I have 2 textBoxes which retrieve text file content, the one is the Source and the other is Destination. Destination is editable but Source is read-only. If I click button Insert, then the selected text from Source will be inserted to the position of active cursor. The question is how to update the cursor position after the insertion? It should moved right after the text inserted. How can I know the last position of the active cursor? Or is there any other way to do this? The insertion part is at the "else" block: Here is my code : if (textBox2->SelectedText != String::Empty) { textBox1->Copy(); textBox2->SelectedText = textBox2->SelectedText->Replace(textBox2->SelectedText,Clipboard::GetText()); textBox2->Focus(); textBox2->Select(textBox2->SelectionStart + Clipboard::GetText()->Length, 0); } else { // INSERTION PART textBox2->Text = textBox2->Text->Insert(textBox2->SelectionStart, textBox1->SelectedText); textBox2->Focus(); textBox2->Select(textBox1->SelectedText->Length - textBox2->SelectionStart,0); } Thank you very much..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this