Windows Develop Bookmark and Share   
 index > Windows Forms General > How to add controls dynamically depending of the type of an enum? Which Design Pattern...?
 

How to add controls dynamically depending of the type of an enum? Which Design Pattern...?

Hello everyone,

I have an enum:

enum MyFormType
{
MyForm1,
MyForm2,
MyForm3,
MyForm4
};

Basically I have a Window Form with a Panel docked at the bottom. I'd like to add buttons with actions to this panel dynamically without having many if and else's all over the place... i.e.:

MyForm1 should have 3 buttons:
Print, Save, Cancel

MyForm2 should have 4 buttons:
View, New , Save, cancel

etc

I want to have an object/class to control this depending of the MyFormType. That way it can grow dynamically without having to do changes in many places.

Would you have a Decorator? a Builder which would return a collection of buttons depending of the MyFormType?

Which design pattern or technique would you say I need to apply in here to achieve this?

Thanks

Federico Silberberg  Tuesday, October 28, 2008 7:05 PM

Any tips? Is there a better forum for this type of question?

Federico Silberberg  Friday, October 31, 2008 1:11 AM

Hi

Appologise but its bit confusing will please brief it again such that i can try to help U out.

Sreenath G V  Friday, October 31, 2008 4:14 AM

We are changing the issue type to “Comment�because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question�by editing your initial post and changing the radio button at the top of the post editor window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.

Thank you!

Bruce.Zhou  Monday, November 03, 2008 12:52 PM

You can use google to search for other answers

Custom Search

More Threads

• change splitter color
• how to tell when a UserControl is going away (removed from form or form closing)?
• Connecting to SQL Server & Web Services
• Problem with ListView Indent after SmallImageList was !=null
• How do I draw an image at the actual size (pixel-wise)?
• Fade in / out all objects
• Accessing the Parent Form Controls
• ListView in c#
• Winforms decoupling.
• Control.ControlCollection reordering