this.estateoperation = "CHANGE";
if(??){
this.button0.Click += new System.EventHandler(this.button0_Click);
}
pushestate();
打??的地方该怎么写.或者用有其它什么方法?
if(??){
this.button0.Click += new System.EventHandler(this.button0_Click);
}
pushestate();
打??的地方该怎么写.或者用有其它什么方法?
this.button0.Click += new System.EventHandler(this.button0_Click);
}直接写成
this.button0.Click += new System.EventHandler(this.button0_Click);
就可以了
在这个地方不需要判断什么
...
this.button0.Click += new System.EventHandler(this.button0_Click);
...
this.button0.Click -= new System.EventHandler(this.button0_Click);
...function(){
...
this.button0.Click += new System.EventHandler(this.button0_Click);
...
}
如果function被调用多次, button0_Click()就会被执行多次
如果没有定义会编译部通过的。
if(this.button0.Click == null){
this.button0.Click += new System.EventHandler(this.button0_Click);
}
{
this.button0.Click += new System.EventHandler(this.button0_Click);
}
if(this.button0.Click == null){
this.button0.Click += new System.EventHandler(this.button0_Click);
}
-----------------------------------
会编译时出错吧
Type t = typeof(Control);
PropertyInfo pi = t.GetProperty("Events", BindingFlags.NonPublic| BindingFlags.Instance);
EventHandlerList el = (EventHandlerList)pi.GetValue(button1,null);
FieldInfo fi = t.GetField("EventClick", BindingFlags.NonPublic | BindingFlags.Static);
Delegate d = el[fi.GetValue(button1)];
if( d == null ) ...
...
this.button0.Click += new System.EventHandler(this.button0_Click);
...
this.button0.Click -= new System.EventHandler(this.button0_Click);
this.clickestate=true;
...function(){
...
if(this.clickestate)
{
this.button0.Click += new System.EventHandler(this.button0_Click);
this.clickestate=false;
}
...
}