NLog control to an existing RichTextBox Windows Form

后端 未结 5 988
醉梦人生
醉梦人生 2021-01-13 01:21

Below is my NLog configuration, I want to load log into existing RichTextBox called rtMessage in Form1, but NLog will create a new windows with log message loaded into the R

5条回答
  •  独厮守ぢ
    2021-01-13 01:43

    Here are three tips to help you load log in existing RichTextBox.

    1. Ensure formName and controlName is consistent with the actual use
    2. Set allowAccessoryFormCreation="False" in NLog.config
    3. RichTextBoxTarget.ReInitializeAllTextboxes(this); in Form_Load

    PS:Follow this way, you neeed to config your RichTextBoxTarget in NLog.config, please refer RictTextBoxTarget.

提交回复
热议问题