你好这个代码按下后按下append text
到textBox
。它为每个按键写一行。请问是否有任何好的解决方案来收集例如5个按键并将它们写入一行?收集多个按键事件
private void User_KeyPress(object sender, KeyPressEventArgs e)
{
textBox.AppendText(string.Format("You Wrote: - {0}\n", e.KeyChar));
textBox.ScrollToCaret();
}
例如鼠标不会这样写:
You Wrote: M; You Wrote: O; You Wrote: U; You Wrote: S; You Wrote: E
但输出将是:
You wrote: MOUSE
感谢您的回答,但不会使用'.AppendText',这意味着之前编写的内容将被新的'keypress'事件重写? – Marek
更新了我的答案。 –