开发者

How can I show/hide a RichTextBox target with NLog? [duplicate]

This question already has answers here: How can I use NLog's RichTextBox Target in WPF application? (2 answers) Closed 7 years ago.

I'm having two little problems that I need help with...

1) If I'm using a RichTextBox target without a form name (ie. it's creating it's own form), how can I show/hide the form that it creates? (I'd like a shortcut key in my application to be able to show/hide the log window, etc)

2) If I specify a form name and control name fo开发者_如何学JAVAr my RichTextBox target control, NLog still creates it's own window. It seems like it's doing this because my log form (frmLog) isn't created until somebody clicks "Show Log Window" (button) on my main form. How can I get around this?


Don't create the logger until the form is loaded.

Private Shared Logger As NLog.Logger = Nothing

Private Sub NewForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    NOTE: had to create this after form had loaded, couldn't do it during static initialization
    Logger = LogManager.GetCurrentClassLogger()
End Sub
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜