views:

58

answers:

2

Let's say you have two classes that extend UserControl. Each of the controls provides a custom event (this could be done by using an interface).

You want to display one of the controls in the odd days and the other in the even days.

You also want to be able to drag&drop (Visual Studio) the UserControl on your form without knowing what the Control type will finally be.

How do you do that ? Is the factory pattern useful here ?

+2  A: 

I would make a container control that is added on the form (and that is present in the designer toolbox), that internally uses some factory to create an instance of the actual control to use and then adds it to the container with Dock set to Fill.

Fredrik Mörk
A: 

You could make a third usercontrol that creates & hosts the usercontrol depending on the day.

But, this has a bad feeling to it, could you explain more in detail what you actually are trying to do?

Stormenet
user1112111