例如 TextBox1.TextChanged += delegate(object sender2, EventArgs e2)
{
TextBox TextBoxOther = new TextBox();
TextBoxOther = ((TextBox)sender2);
//取消 TextBoxOther的TextChanged
TextBoxOther.Undo();
}
};
}最好代码能跑过
{
TextBox TextBoxOther = new TextBox();
TextBoxOther = ((TextBox)sender2);
//取消 TextBoxOther的TextChanged
TextBoxOther.Undo();
}
};
}最好代码能跑过
背后实际上是一大堆的TEXTBOX 一次写10来个TEXTCHANGE事件 很头大的
TextBoxOther = ((TextBox)sender2);
两行合起来就好,没必要new一个多余的出来你把事件处理写一个方法,循环注册事件不就好了?for(int i=0; ....)
{
txt = new TextBox();
txt.ID = i;
txt.TextChanged += 事件处理方法;
panel1.Controls.Add(txt);
}
if(txt.ID == "5")
txt.TextChanged -= 事件处理方法;
可以参考这个清空事件全部的订阅。但是最好不要用匿名委托,因为如果有不止一个委托,区分它们是困难的。
原本是 写成一行的 但是会出错的
出错 : 未处理的“System.StackOverflowException”类型的异常出现在 C1102.dll 中。