Reputation: 5709
Whenever I do richtextbox1.Clear()
it says the method doesn't exist. And it's pretty much the only solution I get, everywhere I go.
I've tried looking for a Text
property, and I've tried to look through the Document
property as well, but to no avail.
What I am missing? The box needs to be cleared, like you can do with a textbox.Clear()
call.
Upvotes: 13
Views: 22550
Reputation: 17
The correct way to do this for Windows Forms is to do richTextBox.ResetText();
Upvotes: 0
Reputation: 12834
If you are adding some controls into the richTextBox (e.g. below):
LinkLabel link = new LinkLabel();
richTextBox1.Controls.Add(link);
you have to use
richTextBox1.Controls.Clear();
to remove all controls.
Upvotes: 1
Reputation: 4218
You can clear a RichTextBox with richTextBox.Document.Blocks.Clear();
Upvotes: 42