OT: Control responsiblities

OT: Control responsiblities

Old forum URL: forums.lhotka.net/forums/t/2020.aspx


ajj3085 posted on Friday, December 22, 2006

Hi,

I have a main MDI form, which has an UltraExplorerBar docked to the left to mimic the look and feel of Outlook 2003.  To create a folder structure (like your mail folders in Outlook 2003), I created custom controls which are hosted for each group.

Currently these controls define events which the main form listens to, like AllContactsClicked or MonthlyPurchases clicked.  The main form 'knows' that AllContacts clicked means to load a list of all contacts and display it in the list form as a MDI child.

My question is, is that the best way to do this, or should the control know how to interperate the node click itself, do the load, and ask the containing form to display the resultant form?  Or is there third way that is the best method to handle this? 

At the moment, I don't have enough time to learn how to use the CAB ent lib..

Thanks
Andy

dshafer replied on Friday, December 22, 2006

Andy,

I think your idea of having the controls define events is fine and I would handle this type of scenario in a similar fashion.  If you are planning on having a lot of these "folder controls", you may want to consider defining one event and having all of the click of the "folder controls" trigger the same event.  You could then indicate which "folder control" was clicked in the event args...That way the main form would only have to subscribe to one event and could use the event args to determine which "folder control" was clicked, and therefore which MDI child form to load.....Just a thought.

ajj3085 replied on Friday, December 22, 2006

Ya, I think that will be my next step.  Thanks for the feedback, glad to know I'm not off base.

Andy

SonOfPirate replied on Friday, December 22, 2006

Yea, empowering the main form with the knowledge of how to respond to the events is a good way to go.  It is consistent with CAB and can be stretched to fit MVC - or at least close to it.  So, when you find the time to venture into those areas, you've got a head start.  My suggestion is try and keep all of the "navigation" logic like this in one place so that it is easier to make changes later.  If you start putting logic in the listbar, menus, toolbars, etc., you'll have a much harder time dealing with it later.

Plus, you can have a method in your main form that handles what needs to be done when AllContactsClicked occurs and route to that method from not only the listbar but a menu item as well (if you have one for that function).  This ensures that all of your behavior is consolidated and consistent.

 

ajj3085 replied on Friday, December 22, 2006

Some good points I hadn't thought about.  I did have multiple ways to load things before, but I'm actually starting to move away from that somewhat to keep things nice and simple for my users.

I'm trying to keep the common requests which in the tasks area to the left, and the user can do more advanced things through the menus. 

I think its working well so far.

Andy

Copyright (c) Marimer LLC