B
bjjnova
I need help dynamically resetting an event handler.
I have a form with several buttons. I have intialized the Click event
of a particular button thus on the form:
_button_3.Click += new
EventHandler(the_controller.onButton3Click_NewEE);
On the same form, I am establishing a property so that I can reset the
Click event from another class (first part of my question: how do I
establish the get accessor since _button_3.Click has to be on the left
side of += or -=?):
public EventHandler Button3Click{
get { ; }
set { _button_3.Click += value; }
}
To dynamically change the event handler, I want to reset it from
another class containing my Click methods but I have to have the get
accessor (in this case, I want to reset the Click even on button 3
when I click on button 5):
public void onButton5Click(Object o, EventArgs e){
if (some condition){
the_form.Button3Click += new EventHandler(this.onButton3Click_A);
}else{
the_form.Button3Click += new EventHandler(this.onButton3Click_B);
}
}
I also need to remove the event handlers, don't I?
I have a form with several buttons. I have intialized the Click event
of a particular button thus on the form:
_button_3.Click += new
EventHandler(the_controller.onButton3Click_NewEE);
On the same form, I am establishing a property so that I can reset the
Click event from another class (first part of my question: how do I
establish the get accessor since _button_3.Click has to be on the left
side of += or -=?):
public EventHandler Button3Click{
get { ; }
set { _button_3.Click += value; }
}
To dynamically change the event handler, I want to reset it from
another class containing my Click methods but I have to have the get
accessor (in this case, I want to reset the Click even on button 3
when I click on button 5):
public void onButton5Click(Object o, EventArgs e){
if (some condition){
the_form.Button3Click += new EventHandler(this.onButton3Click_A);
}else{
the_form.Button3Click += new EventHandler(this.onButton3Click_B);
}
}
I also need to remove the event handlers, don't I?