C# Event Handling Questions
-
I am writing an application that basically has an sidebar and form_view_panel. This sidebar has X amount of buttons on it which correspond to loading specific forms in the form_view_panel. What I need to do is raise an event to the forms in the form_view_panel to let it know when a form change is about to occur(i.e. a toolbar button was clicked), if it(the form in the form_view_panel) wants to allow this to occur at that specific time then it responds back allowing the changing process to occur ORif it doesnt want to change at that point in time that it responds back not allowing the change to occur. So any suggestions on how to implement this using C# event handling methods. Any help will be greatly appreciated. Thank You
-
I am writing an application that basically has an sidebar and form_view_panel. This sidebar has X amount of buttons on it which correspond to loading specific forms in the form_view_panel. What I need to do is raise an event to the forms in the form_view_panel to let it know when a form change is about to occur(i.e. a toolbar button was clicked), if it(the form in the form_view_panel) wants to allow this to occur at that specific time then it responds back allowing the changing process to occur ORif it doesnt want to change at that point in time that it responds back not allowing the change to occur. So any suggestions on how to implement this using C# event handling methods. Any help will be greatly appreciated. Thank You
If I understand correctly, you wanted to send a button-click event from one form to another. First, a button-click event has to be first handled by its container form. It cannot be sent to or handled by another form. This is how event model should work. That said, you still can notify any other forms that something interesting has happened. The simpliest (may not be beast) approach is making a callback into any interested forms from within the event handler and let them to further process the event if necessary. Hope this helps. Best, Jun
-
If I understand correctly, you wanted to send a button-click event from one form to another. First, a button-click event has to be first handled by its container form. It cannot be sent to or handled by another form. This is how event model should work. That said, you still can notify any other forms that something interesting has happened. The simpliest (may not be beast) approach is making a callback into any interested forms from within the event handler and let them to further process the event if necessary. Hope this helps. Best, Jun
-
I am writing an application that basically has an sidebar and form_view_panel. This sidebar has X amount of buttons on it which correspond to loading specific forms in the form_view_panel. What I need to do is raise an event to the forms in the form_view_panel to let it know when a form change is about to occur(i.e. a toolbar button was clicked), if it(the form in the form_view_panel) wants to allow this to occur at that specific time then it responds back allowing the changing process to occur ORif it doesnt want to change at that point in time that it responds back not allowing the change to occur. So any suggestions on how to implement this using C# event handling methods. Any help will be greatly appreciated. Thank You
See the MVC pattern on Wikipedia.com. The Controller can be used to provide the messaging across different views so that the views remain isolated.
-
The last thing you said is very interest...this callback seems to me to be at least a path for me to go down. Do you know have or know of any code examples?
Here is some pseudo code:
private void ButtonHandler(object sender, System.EventArgs e) { // code to cook someParameters is omitted here if(sender == this.buttonAdd) { anotherForm.AddCallback( someParameters ); } else if(sender == this.buttonModify) { anotherForm.ModifyCallback( someParameters ); } else if(sender == this.buttonDelete) { anotherForm.DeleteCallback( someParameters ); } }
Best, Jun