Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How do I use one form showing to different look

How do I use one form showing to different look

Scheduled Pinned Locked Moved C#
helpquestioncsharpc++sales
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tony_Joh
    wrote on last edited by
    #1

    Hello!! I'm using C# Assume I have an application containing a form named form.cs. When you create the look for the form you use the form designer to construct the look that you want. All changes that you do in form designer are put into method InitializeComponent. Assume the form have many more controls than these three controls mentioned just below. The controls that are interesting for my question are: Two buttons called put_in_box and get_from_box. One label showing the correct time. One datagrid. The property for these controls is located in the InitializeComponent as I mentioned earlier. Assume another customer requirement on the form is quite similar to form form.cs. The only difference is that some controls should not be displayed and some other controls be added instead. The followings controls should not be displyed for the new customer. The two buttons named put_in_box and get_from_box. A label showing current time. A datagrid. The new customer want to have a combobox in the same location as the datagrid. We can assume that if you compare the appearance of the form between the two customer much is the same. Now to my problem. 1. I want to have only one form in this case form.cs. So no duplication of code. 2. In an easy way being able to have two appearance(look) of the same form which is named form.cs. 3. Being able to change the appearance(look) for any of these two customer in an easy way.. 4.The form designor is always looking for InitializeComponent when you want to change the appearance(the look) for the form. 5. If I had used MFC I would have used the resource files which store the look for a form in a named resource file. One customers look had been stored in one resource file and the other customer look would have been stored in another resource file but the code would only be in one place so no duplicate code I can't find any good solution to my problem. - One solution which is bad is to have two forms having one form for each customer which also duplicate the code. For example having form.cs and form_xyz.cs - Another solution which is very bad is to have two InitializeComponent InitializeComponent_abc and InitializeComponent_xyz. One for each customer. When you want to edit the appearance(the look) for a customer xyz you have to rename InitializeComponent_xyz to InitializeComponent because the form designed is always looking for InitializeComponent. As a summary a lot of renaming here and there. I wonder if you could help me w

    V 1 Reply Last reply
    0
    • T Tony_Joh

      Hello!! I'm using C# Assume I have an application containing a form named form.cs. When you create the look for the form you use the form designer to construct the look that you want. All changes that you do in form designer are put into method InitializeComponent. Assume the form have many more controls than these three controls mentioned just below. The controls that are interesting for my question are: Two buttons called put_in_box and get_from_box. One label showing the correct time. One datagrid. The property for these controls is located in the InitializeComponent as I mentioned earlier. Assume another customer requirement on the form is quite similar to form form.cs. The only difference is that some controls should not be displayed and some other controls be added instead. The followings controls should not be displyed for the new customer. The two buttons named put_in_box and get_from_box. A label showing current time. A datagrid. The new customer want to have a combobox in the same location as the datagrid. We can assume that if you compare the appearance of the form between the two customer much is the same. Now to my problem. 1. I want to have only one form in this case form.cs. So no duplication of code. 2. In an easy way being able to have two appearance(look) of the same form which is named form.cs. 3. Being able to change the appearance(look) for any of these two customer in an easy way.. 4.The form designor is always looking for InitializeComponent when you want to change the appearance(the look) for the form. 5. If I had used MFC I would have used the resource files which store the look for a form in a named resource file. One customers look had been stored in one resource file and the other customer look would have been stored in another resource file but the code would only be in one place so no duplicate code I can't find any good solution to my problem. - One solution which is bad is to have two forms having one form for each customer which also duplicate the code. For example having form.cs and form_xyz.cs - Another solution which is very bad is to have two InitializeComponent InitializeComponent_abc and InitializeComponent_xyz. One for each customer. When you want to edit the appearance(the look) for a customer xyz you have to rename InitializeComponent_xyz to InitializeComponent because the form designed is always looking for InitializeComponent. As a summary a lot of renaming here and there. I wonder if you could help me w

      V Offline
      V Offline
      Vikram A Punathambekar
      wrote on last edited by
      #2

      Tony, It sounds like these are different applications, so I'd suggest creating different forms. Also, don't do *anything* to the code inside InitializeComponent() - your changes will most probably be lost. Instead, in the form ctor, add your changes *after* the call to InitializeComponent(). HTH. :) Cheers, Vikram.


      "When I read in books about a "base class", I figured this was the class that was at the bottom of the inheritence tree. It's the "base", right? Like the base of a pyramid." - Marc Clifton.

      T 1 Reply Last reply
      0
      • V Vikram A Punathambekar

        Tony, It sounds like these are different applications, so I'd suggest creating different forms. Also, don't do *anything* to the code inside InitializeComponent() - your changes will most probably be lost. Instead, in the form ctor, add your changes *after* the call to InitializeComponent(). HTH. :) Cheers, Vikram.


        "When I read in books about a "base class", I figured this was the class that was at the bottom of the inheritence tree. It's the "base", right? Like the base of a pyramid." - Marc Clifton.

        T Offline
        T Offline
        Tony_Joh
        wrote on last edited by
        #3

        Hello!! The main point is to avoid having to duplicate the code but if I use your suggestion then the code will be duplicated when I have two forms. If I understand you right as you say these will be two separate application having it's own lives with it's own form. Assume instead that the form between two customer were identical accept the colour on one single button. Do you still suggest that the best suggestion is to have two different application with it's own form. I don't know if you are familiar with MFC but as I mentioned in the previous mail this is easy to solve in MFC. So do you think that there doesn't exist any solution which is as good as the MFC solution of this problem. If I just mention resource files. Resource files is having a different meaning and purpose in .Net compare to MFC. So to use resource files to solve my problem is not posssible in .NET(C#). //Tony

        D 1 Reply Last reply
        0
        • T Tony_Joh

          Hello!! The main point is to avoid having to duplicate the code but if I use your suggestion then the code will be duplicated when I have two forms. If I understand you right as you say these will be two separate application having it's own lives with it's own form. Assume instead that the form between two customer were identical accept the colour on one single button. Do you still suggest that the best suggestion is to have two different application with it's own form. I don't know if you are familiar with MFC but as I mentioned in the previous mail this is easy to solve in MFC. So do you think that there doesn't exist any solution which is as good as the MFC solution of this problem. If I just mention resource files. Resource files is having a different meaning and purpose in .Net compare to MFC. So to use resource files to solve my problem is not posssible in .NET(C#). //Tony

          D Offline
          D Offline
          darkelv
          wrote on last edited by
          #4

          There may be no best solution for it but here's some of my thoughts: 1. Seperate the logic and interface. You duplicate codes on the form but keeping the logics in 1 place. Probably this is too late for you to do now. 2. Have only 1 form, but a lot of switches to turn on/off the controls. But it will get very messy and confusing. I have seen forms and panels overlapping each other in one of our product and it's a nightmare just to look at the codes. 3. Put the core stuffs in a base form and inherit the forms into 2 forms (possible?), add new requirement on each new forms as required. If you have a 3rd requirement for new customer, it can support it well enough. 4. Duplicate everything into 2 forms. Harder to maintain but not as bad as (2). Out of these few, I think 1 and 3 are the better one.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups