Conditional Form1.Designer.cs
Hello,
Is it possible to have a Form, e.g. Form1 that has multiple Designer files?
For example:
Quote:
Form1.cs
-Form1_1.Designer.cs
-Form1_2.Designer.cs
-Form1_3.Designer.cs
Now if Form1 was opened by the form Form2 then in Form2 I would like something like this:
Code:
//in button1 click..
int myNum = 2;
switch(myNum)
{
case 1:
LoadForm1Designer("designerfiles/Form1_1.Designer.cs");
Form1 frm = new Form1();
frm.Show();
break;
case 2:
LoadForm1Designer("designerfiles/Form1_2.Designer.cs");
Form1 frm = new Form1();
frm.Show();
break;
case 3:
LoadForm1Designer("designerfiles/Form1_3.Designer.cs");
Form1 frm = new Form1();
frm.Show();
break;
}
I know the issue with this would be that the code would have to be compiled at runtime. Is there another solution? The reason I would rather select from different designer files instead of just creating the controls in Form1_Load is because I am combining the GUIs of several different applications that have the same code but have different GUIs. Does anyone have a solution to my problem, or perhaps another method that I haven't thought of?
Re: Conditional Form1.Designer.cs
What you're asking for is not happening. You need to either create your controls at run time or else create three separate forms. Those three forms could inherit a single base form if you want to be able to build common functionality only once. That's exactly what inheritance is for.