我想在按下回车键时从文本框中捕获文本.我正在使用 WPF/visual studio 2010/.NET 4.我不知道要在标签中使用什么事件处理程序?我也想对 maskedtextbox 做同样的事情.
I want to capture the text from the textbox when enter key is hit. I am using WPF/visual studio 2010/.NET 4. I dont know what event handler to be used in the tag ? I also want to do the same for maskedtextbox.
KeyDown 或 KeyUp.
Either KeyDown or KeyUp.
TextBox tb = new TextBox();
tb.KeyDown += new KeyEventHandler(tb_KeyDown);
static void tb_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
//enter key is down
}
}
这篇关于输入按键事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!