Results 1 to 2 of 2

Thread: Conditional Form1.Designer.cs

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2008
    Posts
    1,754

    Conditional Form1.Designer.cs

    Hello,

    Is it possible to have a Form, e.g. Form1 that has multiple Designer files?

    For example:

    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?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width