How to deleted two characters to the left of the cursor in a RichTextBox in Silverlight

I need help with code for the click event of a Button1 that will delete two characters to the left of the current cursor position in a richTextBox1 on a Silverlight 4 Page.  

Therefore if the following the text in richTextBox1 before clicking Button1 (with the cursor currently being just after the full stop)

This is a simple sentencee.

After clicking Button1 it should look like

This is a simple sentence

Please note that clicking Button1 has deleted full stop and the extra e at the end of the word "sentence"

Thank you for your help in anticipation.

LVL 1
FaheemAhmadGulAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

saraganiCommented:
Hi, sorry for the delay, I was kinda busy. Here is a solution:

            TextSelection textRange = richTextBox1.Selection;
            TextPointer tp = textRange.Start;
            TextPointer startPos = tp.GetPositionAtOffset(-2, LogicalDirection.Forward);
            textRange.Select(startPos, tp);
            richTextBox1.Selection.Text = "";


The idea of this solution is setting the selection from the start of the cursor 2 chars backwards and then setting the selected text to be an empty string.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FaheemAhmadGulAuthor Commented:
Excellent!
Many thanks. Regards
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.