首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

怎么根据光标的位置确定回车对应的按钮

2012-01-05 
如何根据光标的位置确定回车对应的按钮?Button1的事件里:LabelTip.Textthis.TextBox1.TextButton2的事件

如何根据光标的位置确定回车对应的按钮?
Button1的事件里:

LabelTip.Text=this.TextBox1.Text;


Button2的事件里:

LabelTip.Text=this.TextBox2.Text;



在TextBox1里面输入"Good Luck!", 在TextBox2里输入"Pretty girl!"


当光标在TextBox1时,用户按下回车键后,Label就显示Good Luck!当光标在TextBox2时,用户按下回车键后,Label就显示Pretty girl!



这种效果如何实现?好像不太容易实现.

谢谢了.

[解决办法]
private void textBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if(e.KeyCode==Keys.Enter)
this.label1.Text = this.textBox1.Text;
}
[解决办法]
用TEXTBOX的事件!然后判断按键值满足什么时出现什么样的结果!

热点排行