RichTextBox doesn't update caret position correctly

Posted by shadeMe on Stack Overflow See other posts from Stack Overflow or by shadeMe
Published on 2010-04-20T05:36:30Z Indexed on 2010/04/20 5:53 UTC
Read the original article Hit count: 363

Filed under:
|
|
|

I have a handler consuming the keyDown event of a WinForms RTB, that has the following code:

GetTextAtLoc(RTB->SelectionStart); // selects some text at the caret's position
RTB->SelectedText = "SomeOfMyOwn";
GetTextAtLoc(RTB->SelectionStart); // selects the replacement string
RTB->SelectionStart += RTB->SelectionLength - 1;

While this code seems to do its job (SelectionStart/Length properties are updated correctly), the caret doesn't move to the end of the new string - It says right where it was at the time of GetTextAtLoc's first call. Redrawing the textbox does seem to have any effect either.

© Stack Overflow or respective owner

Related posts about c++-cli

Related posts about richtextbox