且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

一个用于所有事件的事件处理程序

更新时间:2023-12-06 11:11:16

步骤
------
1.用代码编写一个TextChange事件.
2.打开表单设计器.
3.选择要共享其公共TextChange事件的必需文本框.
4.打开属性窗口或按F4(单击事件)
5.在属性窗口的TextChange事件中,选择您在代码中编写的TextChange事件.
6.按Enter.

无需编写代码!
:)
Steps
------
1. Write a TextChange event in code.
2. Open form designer.
3. Select required textboxes for which you want to share common TextChange event.
4. Open property window or press F4 (click event)
5. In TextChange event of property window, select TextChange event written by you in code.
6. Press enter.

No need to make code!
:)




这应该可以解决问题:

Hi,

this should do the trick:

foreach (Control ctrl in this.Controls)
{  
  if (ctrl is TextBox)
  {
    ctrl.TextChanged += new EventHandler(txt_TextChanged);
  }
}