Toolbar switching / dynamic population
Hello members,
I am new to DotNet and have a problem.
I am developing a Windows Forms MDI application using C#.
I need to switch the toolbars or, to be more precise, need different buttons/icons on the toolbar depending on which child window is active. Each Child window has its own set of toolbar buttons. (for eg. Order screen has its set of buttons, while Customer has its set of buttons). Also when all child windows are closed, and only the MDI window is active, it needs to display a different set of buttons. There will also be some common buttons for all the child windows, such as for Cut,Copy,Paste,Exit,Lookup,Search etc.
What is the best way to do this ?
1. Create a separate toolbar for each child window ? But in this case, the toolbar does not get attached to the MDI window. It gets attached to the indicidual child windows. Also it means I have to create that many toolbar and imagelist objects as the number of modules that I have ( 60+).
2. Or can I just create a single toolbar which is attached to the MDI window, but somehow, at runtime, depending on which child window is active, make a different set of butons appear on the toolbar. In this case how do I specify what is to be executed when a toolbar button is clicked. Also, the same button may need to different things depending on the module in which it has been clicked (for eg. clicking on "Analyse" button calls different database procedures depending on the active module)
Example situation.
Application loads. MDI window is displayed with toolbar having only two buttons, Connect and Disconnect.
User activates Order screen from the menu. Order window opens and the toolbar now displays the buttons relevant to the Orders module.
While Orders module is open, user now opens Customers module. When the Customers window loads, the toolbar now displays the buttons relevant to the Customer module.
User clicks on the Orders window and makes it the active window. Again the toolbar must show the buttons relevant to the Orders module.
Kinldy help out. Looking forward to your responses.
Thanks,
yamyam
|