Is there way to speed up displaying a lot of text in a winforms textbox?

前端 未结 7 885
天涯浪人
天涯浪人 2020-12-21 14:32

Is there way to speed up displaying a lot of text in a winforms textbox? My application reads a file (which can be as large as 20MB) and then displays it to a textbox (TextB

7条回答
  •  囚心锁ツ
    2020-12-21 15:00

    Solution with minimal change in code will be to read the whole file contents into variable, then append "chunks" of the contents to the textbox in a loop calling Application.DoEvents() in each iteration.

    You can show "Loading please wait..." message while it's still loading, the DoEvents call will ensure your application won't be "frozen" in the meanwhile.

提交回复
热议问题