On some generic functions, it seems that accessing a function on mainform directly from the usercontrol is easier than raising an event. For example: A function on main form that displays one desired usercontrol centered and tweaked.
Making this function static, or access this function by reference from the user control to its parent, rather then raising an event, seems very convenient. Like this:
usercontrol_A uc_a = new usercontrol_A();
MainForm mainform_functions = (MainForm)Parent;
mainform_functions.DisplayControl(uc_a);
Raising an event seems more complex in such cases - I need to declare all new userControl_B's events (which also includes initiating usercontrol_C and displaying it) inside the event that shows (and initiates) userControl_B:
userControl_A.ShowUserControl_B+= (s,e) =>
{
usercontrol_B uc_b = new usercontrol_B(); DisplayControl(uc_b);
uc_b.show_uc_c += (s2,e2) => {usercontrol_C uc_c = new usercontrol_C(); DisplayControl(uc_c); }
}
too much clutter here.
That's hard to code and to read later. (In addition, passing parameters to another usercontrol is a nightmare like this - I need to save the parameter artificially on the sender usercontrol class and then cast it back later inside the event)
What is your opinion? Is it a completely "prohibited" to code like this, at least on generic functions like I mentioned? Isn't clearer code that needs some small tweaking for reuse preferable?