C# – RichTextBox does not constantly update when used as text status display

crichtextboxtextboxwinforms

I'm trying to use a RichTextBox as a status display but it is not updating every time I append to the text of the RichTextBox. A regular multiline TextBox will update everytime new text is appended to it, but I would prefer to use the RichTextBox. Is there some sort of property that needs to be set to see the updates?

UPDATE:
Also, how would I automatically make it scroll down every a message is displayed?

Like I said, if I replace the RichTextBox with a TextBox, I can see each line of the messages as they are getting written out and it will also automatically scroll down to the bottom to display the latest text added.

void UpdateStatus(string textMessage)
{
  if (InvokeRequired)
  {
    BeginInvoke(new MethodInvoker(() => UpdateStatus(textMessage)));
    return;
  }

  richTextBox.AppendText(textMessage + Environment.NewLine);
}

Best Answer

An easy and quick fix would be

Application.DoEvents()

Related Topic