【问题标题】:adding new line to Metro Textbox向 Metro 文本框添加新行
【发布时间】:2016-02-27 18:18:47
【问题描述】:

我将 MetroFramework 用于我的 gui 但我在向 MetroTextbox 添加新行时遇到问题 我试过了

\n\r

\r\n

\r

\n

Environment.NewLine

多行 = 真

【问题讨论】:

    标签: c# textbox newline


    【解决方案1】:

    我找到了一种方法 但我认为不应该这样做

    private List<string> Lines = new List<string>();
            public void WriteLog(string LogString)
            {
                if (this.ServerLogTextbox.InvokeRequired)
                {
                    SetTextCallback Recal = new SetTextCallback(WriteLog);
                    this.Invoke(Recal, new object[] {LogString});
                }
                else
                {
                    Lines.Add("[" + DateTime.Now.ToString("HH.mm.ss") + "]: " + LogString);
                    ServerLogTextbox.Lines = Lines.ToArray();
                }
            }
    

    【讨论】:

      【解决方案2】:

      你需要使用AppendText()如下

                  metroTextBox1.Multiline = true;
                  metroTextBox1.Size = new Size(300, 50);
      
                  metroTextBox1.Text = "";
                  metroTextBox1.AppendText("Line1");
                  metroTextBox1.AppendText(Environment.NewLine);
                  metroTextBox1.AppendText("Line2");
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-07-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多