How to clear text content in RichTextBox

前端 未结 6 704
眼角桃花
眼角桃花 2020-12-15 02:53

After getting the text in the RichTextBox I want to clear the text. How can I do that?

TextRange txt = new TextRange(richtxtSNotice.Document.ContentStart, ri         


        
6条回答
  •  时光取名叫无心
    2020-12-15 03:23

    I found that clearing the richTextBox didn't always remove all of the text from the richTextBox using richTextBox.Text = ""; or richTextBox.Clear(); Only the first few lines were cleared.

    To fix this issue, I included the Update() function call solved this issue.

    richTextBox.Clear();
    

    followed by

    richTextBox.Update();
    

    to reliably clear the richTextBox.

提交回复
热议问题