简体   繁体   English

如何创建类似于Visual Studio日志窗口的输出日志窗口

[英]How to create a output log window similar to visual studio log window

I need to add an output window to my windows form, similar to the output window in visual studio. 我需要在Windows窗体中添加一个输出窗口,类似于Visual Studio中的输出窗口。 在此处输入图片说明

What i have done is created a list box and planning to log the details as and when they arrive. 我所做的是创建一个列表框,并计划在到达时记录详细信息。 I dont know how to add the highlighted button controls (close, windows position, autohide). 我不知道如何添加突出显示的按钮控件(关闭,窗口位置,自动隐藏)。 I am completely new to visual studio, winforms, c#. 我是Visual Studio,Winforms,C#的新手。 Just exploring various things to draft an application. 只是探索各种事物以草拟应用程序。 I would be nice if anyone could suggest ideas in adding those controls. 如果有人可以提出有关添加这些控件的建议,我会很好。

And also please suggest if there is an alternative to list box to display the output window. 并且还建议是否有替代列表框的选项来显示输出窗口。

You can use SplitContainer and add Textbox or RichTextbox as output window you want. 您可以使用SplitContainer并将Textbox或RichTextbox添加为所需的输出窗口。 You can then append output text to the text property of Textbox ot RichTextbox. 然后,您可以将输出文本附加到TextBox或RichTextbox的text属性中。 Instead of highlighted controls, you can change the size of SplitContainer at run time, or hide one of the section using menu option. 您可以在运行时更改SplitContainer的大小,而不使用突出显示的控件,或使用菜单选项隐藏其中一部分。

~Nilesh 〜Nilesh制作

Based on Sam W 's comment, Using DockPanel would create a another window inside the winform, similar to output, error window in Visual Studio IDE. 根据Sam W的评论,使用DockPanel将在winform中创建另一个窗口,类似于Visual Studio IDE中的输出错误窗口。

dockpanelsuite.com dockpanelsuite.com

This site provides amazing Docking Features http://docs.dockpanelsuite.com/ provides steps to install them. 该站点提供了令人惊叹的Docking功能http://docs.dockpanelsuite.com/提供了安装它们的步骤。

In Form 1, set isMidiContainer = true in Form1's Properties and drag the DockPanel from toolBox(after installing and following steps in that page). 在Form 1中,在Form1的Properties中设置isMidiContainer = true ,然后从toolBox拖动DockPanel(在安装并执行该页面中的步骤之后)。

create a form2 and add the following 创建一个form2并添加以下内容

using WeifenLuo.WinFormsUI.Docking;

namespace Forms
{
  public partial class Form2 : DockContent
  {
     public Form2()
    {
       InitializeComponent();
    }
 }
}

In Form1 add 在Form1中添加

public Form1()
{
  InitializeComponent();
  Form2 f2 = new Form2();
  f2.Show(dockPanel, DockState.DockBottom);
}

We can add many more forms and dock them to one parent form. 我们可以添加更多表格并将其停靠到一个父表格中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM