how to delete RichTextBox selection?

  • Thread starter Thread starter Mark Smith
  • Start date Start date
M

Mark Smith

My understanding is that you can delete selected text in a RichTextBox
by setting the selection to an empty string. This doesn't work for
me. For instance, if I do this (C#):

...
richTextBox.AppendText("ABC");
richTextBox.Select(1, 1);
richTextBox.SelectedText = "b";
richTextBox.AppendText("D");

I get "AbCD" as I'd expect. But if I do this:

...
richTextBox.AppendText("ABC");
richTextBox.Select(1, 1);
richTextBox.SelectedText = "";
richTextBox.AppendText("D");

I get "ABCD". (In other words, the selection isn't deleted.) Am I
missing something obvious?
 
Back
Top