如何在cmd框中实现上下键回溯历史记录 方法已经知道了,参考了以下的做法:http://blog.csdn.net/linjf520/article/details/8187637但有个问题是如何在keydown事件中按了上下键后不停的回溯历史记录呢?还有就是如何让光标停留在最后一行的末尾处,我按了上下键光标老是跑上去了,请各位帮忙了,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 addSendRec函数里最后一句代码应该是下面这样吧sendRecordListIdx = sendRecordList.Count-1;光标停在最后一行末尾 this.textBox_send_chat_txt.SelectionStart = this.textBox_send_chat_txt.Text.Length-1; this.textBox_send_chat_txt.SelectionLength = 1; 在keyDown事件里最后写上下面这句代码,光标就不往上跑了e.Handled = true; if (e.KeyCode == Keys.Up) { this.textBox_send_chat_txt.Text = upGetSendRec(); } else if (e.KeyCode == Keys.Down) { this.textBox_send_chat_txt.Text = downGetSendRec(); }e.Handled = true; //你测一下,如果不行,就把这句放在此函数第一行试试 你不是已经实现了吗?upGetSendRec()和downGetSendRec()函数里不是获取最后一行的记录吗 if (e.KeyCode == Keys.Up){ this.textBox_send_chat_txt.Text = upGetSendRec();}else if (e.KeyCode == Keys.Down){ this.textBox_send_chat_txt.Text = downGetSendRec();}textBox_send_chat_txt是多行文本,他这里这么写的话就直接替换为历史记录行了,要textBox_send_chat_txt.AppendText(upGetSendRec())或textBox_send_chat_txt.AppendText(downGetSendRec()),但这样的话就按上下键就无限的往后添加历史记录行,做法是要先删除最后一行的内容然后在AppendText C# chart控件时间轴如何放大 datagridview 如何打开自动定位到最后一行 label.text如何换行 mdi窗口,通过子窗口,调用另一个子窗口。怎么弄?谢谢。 问一个弱弱的问题 【virtual new】 联合定义方法如何理解 用一条SQL语句查询问题???高手帮忙呀!!! winform如何和Flash通信 怎样正确显示他国语言的文件?就像IE一样会自动识别编码? c# windows service中读取证书存储区信息失败,如何处理 登陆系统后toolbar控件时会在屏幕的左上边显示 如何学着使用泛型和反射写一个tool 封装Silverlight wcf 通信接口
sendRecordListIdx = sendRecordList.Count-1;
光标停在最后一行末尾
this.textBox_send_chat_txt.SelectionStart = this.textBox_send_chat_txt.Text.Length-1;
this.textBox_send_chat_txt.SelectionLength = 1;
e.Handled = true;
{
this.textBox_send_chat_txt.Text = upGetSendRec();
}
else if (e.KeyCode == Keys.Down)
{
this.textBox_send_chat_txt.Text = downGetSendRec();
}
e.Handled = true; //你测一下,如果不行,就把这句放在此函数第一行试试
upGetSendRec()和downGetSendRec()函数里不是获取最后一行的记录吗
{
this.textBox_send_chat_txt.Text = upGetSendRec();
}
else if (e.KeyCode == Keys.Down)
{
this.textBox_send_chat_txt.Text = downGetSendRec();
}
textBox_send_chat_txt是多行文本,他这里这么写的话就直接替换为历史记录行了,要textBox_send_chat_txt.AppendText(upGetSendRec())或textBox_send_chat_txt.AppendText(downGetSendRec()),但这样的话就按上下键就无限的往后添加历史记录行,做法是要先删除最后一行的内容然后在AppendText