|
-
June 19th, 2011, 01:03 AM
#1
Moving cursor in Visual Studio 2008
I'm using a TextBox object in my application. The mission is to transform input characters as they are typed (letters only). I'm using string manipulations on TextBox->Text. The problem is that when I'm doing so, the cursor goes to the beginning of line. On the other hand, when the character is typed transparently (without my code), the cursor moves as I type.
My code looks like this:
private: System::Void m_TextPane_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
/*
bla-bla-bla
*/
// transform input char (e->KeyChar) into String, while manipulation on its value
// final char String is in curr_out
// add new char to the typed text
m_TextPane->Text = String::Concat(m_TextPane->Text, curr_out);
}
Any ideas why cursor behaves so and how can I move it to the end of the typed text?
-
June 19th, 2011, 03:48 AM
#2
Re: Moving cursor in Visual Studio 2008
m_TextPane->Text = String::Concat(m_TextPane->Text, curr_out);
m_TextPane->SelectionStart = m_TextPane->Text->Length;
m_TextPane->SelectionLength = 0;
-
June 19th, 2011, 05:57 AM
#3
Re: Moving cursor in Visual Studio 2008
This fixes the problem. Thanks a lot!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|