Applying color for All forms in Winforms

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Manikgisl
    New Member
    • Oct 2008
    • 37

    Applying color for All forms in Winforms

    HI

    can we apply the color for all winforms as skin file as like in Asp.Net

    At design time it happen

    Is it posible


    Thanks

    Mani
  • Ramk
    New Member
    • Nov 2008
    • 61

    #2
    Go to C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\P rojectTemplates \CSharp\Windows \1033\WindowsAp plication.zip(or to the drive where the VS2005 is located)
    and edit the file form1.designer. cs in notepad as below & close it.
    After this change, when you create a new windowsapplicat ion, the form will colored with your color.
    Code:
     
    this.BackColor = System.Drawing.Color.ForestGreen;

    Comment

    • Curtis Rutland
      Recognized Expert Specialist
      • Apr 2008
      • 3264

      #3
      Won't that change every form you create from then on?

      I might suggest using Properties.Sett ings to store your color choices and set the color of the form in the constructor of each form.

      Comment

      • Ramk
        New Member
        • Nov 2008
        • 61

        #4
        Not at all! Because, we edited the form1.designer. cs, so the changes will effect when a new WindowsApplicat ion is created(By default, Form1 is created with the default WndApp project).
        Also, your method works when the application is running if Im not wrong.
        I guess, the questioner is interested to change the back color in design time itself.

        Comment

        • Curtis Rutland
          Recognized Expert Specialist
          • Apr 2008
          • 3264

          #5
          Right, you are suggesting changing the default template? That can be quite useful, as long as you change it back when you don't want to use that color.

          Comment

          • Ramk
            New Member
            • Nov 2008
            • 61

            #6
            Originally posted by insertAlias
            Right, you are suggesting changing the default template? That can be quite useful, as long as you change it back when you don't want to use that color.
            You are correct. Infact, I do like to change the default templates to suite my requirements which could speed up the developement.

            Comment

            • balabaster
              Recognized Expert Contributor
              • Mar 2007
              • 798

              #7
              I'd create a static class that contains a public property that sets the color. In every one of my forms in the Form's Load event I'd set it to the value of the property. Or if in VB, I'd do it in a module...

              Basically what you're doing is creating a CSS type model. Something like

              Code:
              Public Static Class MyStyles
              
                Color DefaultFormColor = Color.Red;
              
              End Class
              Better still, I'd set the color scheme in my config file and have all my forms reference the colors from my config. This way I don't have to recompile to alter my color scheme.

              Comment

              Working...