问:VS C#怎样在一个多行textbox里写键盘事件响应?

来源:百度知道 编辑:UC知道 时间:2024/09/21 15:45:11
我的意思是:在textbox里,输入一个字符串,然后回车,下一行字符串自动出现,光标停在末尾等待再次输入~类似于DOS的命令格式~
如何实现呢?麻烦高手们给下代码!

public partial class Form1 : Form
{
//这个可以自定义你自己的
string pm="C:\\>";
public Form1()
{
InitializeComponent();
textBox1.Text = pm;
textBox1.Select();
textBox1.Select(pm.Length, 0);
}
private void textBox1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
//这个时输入的字符串,不包括前面的那个常驻字符串
string s = textBox1.Text.Substring(pm.Length);
//自己处理这个字符串

textBox1.Text = pm;
textBox1.Select();
textBox1.Select(pm.Length, 0);
}
}
}

textBox1.Select