TextBox[] txtBox = new TextBox[11];
for (int i = 1; i <= 10; i++)
{
string TextBoxName = "txtBox" + i.ToString();
txtBox[i].Name = TextBoxName;
txtBox[i].TextChanged += new EventHandler(txtBox[i]_TextChanged);
}
最后事件txtBox[i]_TextChanged应该怎么生成呢?编译的时候说少括号。
应该怎么写TextChanged 事件啊?

解决方案 »

  1.   

    用匿名方法
    txtBox[i].TextChanged += new delegate{
    代码
    }
      

  2.   

    txtBox[i]_TextChanged 定义了没有?
      

  3.   

    定义了啊
    private void txtBox1_TextChanged(object sender, EventArgs e)
    {}
      

  4.   

    txtBox[i]_TextChanged 不正确只需要定义一个
    Text_ChangedTextBox[] txtBox = new TextBox[11]; 
    for (int i = 1; i  <= 10; i++) 

    string TextBoxName = "txtBox" + i.ToString(); 
    txtBox[i].Name = TextBoxName; 
    txtBox[i].TextChanged += new EventHandler(Text_Changed); 

    想区分具体是哪一个TEXTBOX在这个Text_Changed内处理吧
      

  5.   


    Text_Changed也报错啊错误
    事件“System.Windows.Forms.Control.TextChanged”只能出现在 += 或 -= 的左边
      

  6.   

    txtBox[i].TextChanged += new EventHandler(txtBox[i]_TextChanged); 
    红色的不对,改为你定义的触发函数名称即可。