日期:2014-05-18  浏览次数:21023 次

添加事件?
如何为动态生成的TextBox添加回车事件?请各位大虾帮忙了!谢谢!

------解决方案--------------------
TextBox tb = new TextBox();
tb.KeyPress += new KeyPressEventHandler(tb_KeyPress);

void tb_KeyPress(object sender, KeyPressEventArgs e)
{}
------解决方案--------------------
var textbox1=findcontrol(...);
textbox1.click=new eventhandler(textbox1_click);
------解决方案--------------------
C# code
KeyPressEventHandler handler = (sender, e) => { MessageBox.Show(e.KeyChar.ToString()); };
textBox1.KeyPress += handler;