Defining different layouts for a Windows form.
Hello all -
I have a form with a number of various controls on it. Given different modes my application is running in, I'd like to provide different layouts for this form. I'd like to re-use existing code that interacts with the form because all the controls will still be on it, just in a different layout. In MFC, you can easily do this by providing different dialog templates to the same CDialog or CFormView class. Is there a way to do this easily in C#/.Net?
I don't want to use any of the layout panels, because my controls could be in completely different locations relative to each other. It's best if I could define a different layout and load it at runtime depending on the app mode.
When doing internationalization, a new resx file is generated and in the Designer.cs file of my form, you can provide different text or sizes dynamically using the ApplyResources method on the ComponentResourceManager. The appropriate resx file is loaded for your form based on the culture. I'd like to do something similar, but for the same culture have different layouts.
Any suggestions out there? Thanks in advance.
Re: Defining different layouts for a Windows form.
The easiest thing I can think of (still a lot of coding) would be to dynamically generate the controls at runtime and programmatically wire them to your existing event handlers. This would give you the flexibility of determining the layout at runtime based on the app mode. I know its not the easy out that you are looking for.
The problem is that the layout for a form in c++ is generated at runtime from the template. In C# it is generated at design time, so there is no easy way to substitute at runtime.