Hi, I'm using a RichTextBox class to make some automatic text formatting. And mz question is, how do I get the RichTextBox to put some string immediately after the caret. When I use RichTextBox.CaretPosition.InsertTextInRun("some string") the text is inserted after the current logical block, but I need to be insterted immediately after the caret, in the middle of a Run block. I hope it's clear, thx very much.
A:
Well, to insert text after the caret i would do this:
richTextBox1.Select(richTextBox1.SelectionStart, 0);
richTextBox1.SelectedText = "textToInsert";
If you provide additional information in your question i will attempt to fit my answer better.
Tommy
2010-02-05 03:52:06
The thing is, that I'm using the WPF RichTextBox (in System.Windows namespace), that doesn't have Select method. But the solition you suggest fits my problem, I just need it for the WPF RichTextBox. Thx for help.
Jan Kratochvil
2010-02-05 07:59:59