2023년 10월 19일 목요일

C# RichTextBox를 활용하여 이벤트 진행사항 업데이트하기

동기/비동기 모두 사용 가능.
  1. private void _InsertMessage(string s)
  2. {
  3. string strDatetime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
  4. if (RichTextBox.InvokeRequired)
  5. {
  6. RichTextBox.BeginInvoke(new Action(() => RichTextBox.AppendText("[ " + strDatetime + "] : ")));
  7. RichTextBox.BeginInvoke(new Action(() => RichTextBox.AppendText(s + System.Environment.NewLine)));
  8. RichTextBox.BeginInvoke(new Action(() => RichTextBox.ScrollToCaret()));
  9. }
  10. else
  11. {
  12. RichTextBox.AppendText("[ " + strDatetime + "] : ");
  13. RichTextBox.AppendText(s + System.Environment.NewLine);
  14. RichTextBox.ScrollToCaret();
  15. }
  16. }

댓글 없음:

댓글 쓰기