我使用MetroFramework为我的gui 但我在MetroTextbox中添加新行时遇到问题 我试过了
\ n \ r
\ r \ n
\ r
\ n
Environment.NewLine
MultiLine = true
答案 0 :(得分:0)
我找到了办法 但我想不应该这样做
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();
}
}
答案 1 :(得分:0)
您需要按照以下说明使用AppendText()
metroTextBox1.Multiline = true;
metroTextBox1.Size = new Size(300, 50);
metroTextBox1.Text = "";
metroTextBox1.AppendText("Line1");
metroTextBox1.AppendText(Environment.NewLine);
metroTextBox1.AppendText("Line2");