问题
I currently have a function that will set a value to a RichTextBox, although how could you "add" a value or a new line to it, rather than overwriting existing data in the RichTextBox?
richTextBox2.Text = DateTime.Today + " Hello";
回答1:
richTextBox2.AppendText(Environment.NewLine + DateTime.Today + " Hello");
回答2:
richTextBox2.AppendText(String.Format("{0} the date is {1}{2}", "Hello", DateTime.Today, Environment.NewLine));
Please don't use +
回答3:
richTextBox2.Document.Blocks.Clear();
richTextBox2.Document.Blocks.Add(new Paragraph(new Run("string")));
回答4:
richTextBox2.Text = "Something " + richTextBox2.Text + " and something"
来源:https://stackoverflow.com/questions/6485156/adding-strings-to-a-richtextbox-in-c-sharp