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. Visual Basic
  4. Multiple forms of same look.

Multiple forms of same look.

Scheduled Pinned Locked Moved Visual Basic
question
8 Posts 7 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.
  • R Offline
    R Offline
    Razanust
    wrote on last edited by
    #1

    How can i make multiple forms in a project, having the same look (background color, font etc) in VB 2008?

    K P J D 4 Replies Last reply
    0
    • R Razanust

      How can i make multiple forms in a project, having the same look (background color, font etc) in VB 2008?

      K Offline
      K Offline
      KChandos
      wrote on last edited by
      #2

      If I understand your question correctly, then you first need to determine the lowest common denominator of the forms (font, color, default buttons that are on all forms, etc). Create a regular windows form. Set the properties the way that you want them, save, then close the designer. Add a new Windows Form to the project, but select the "Inherited Form" object instead of the "Windows Form" object. The wizard will ask you which form you want to base the new form on, so select the base that you previously created. When the designed opens up, you will see all of the things that you had set it the original form (and you will not be able to change them), and your new form is ready for adding controls.

      R 1 Reply Last reply
      0
      • R Razanust

        How can i make multiple forms in a project, having the same look (background color, font etc) in VB 2008?

        P Offline
        P Offline
        programmervb netc
        wrote on last edited by
        #3

        There is a gotcha that you should be aware of... If you do much of anything in your load routine. In the base for you will want to put all of that stuff into an if statement that only executes when not in the designer. I am not sure why this is but fought this for about a week. So you would put code in the load routine in an if like this

         If Not DesignMode Then
                'DoStuff
         End If
        

        Also be aware that usually you will want to design the base form then BUILD the project before adding the inherited form.

        Humble Programmer

        L 1 Reply Last reply
        0
        • P programmervb netc

          There is a gotcha that you should be aware of... If you do much of anything in your load routine. In the base for you will want to put all of that stuff into an if statement that only executes when not in the designer. I am not sure why this is but fought this for about a week. So you would put code in the load routine in an if like this

           If Not DesignMode Then
                  'DoStuff
           End If
          

          Also be aware that usually you will want to design the base form then BUILD the project before adding the inherited form.

          Humble Programmer

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Visual Designer executes parts of your code, that is how it renders the Forms and User Controls you create. Unfortunately I don't have any details around. :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


          Getting an article published on CodeProject should be easier and faster.


          1 Reply Last reply
          0
          • K KChandos

            If I understand your question correctly, then you first need to determine the lowest common denominator of the forms (font, color, default buttons that are on all forms, etc). Create a regular windows form. Set the properties the way that you want them, save, then close the designer. Add a new Windows Form to the project, but select the "Inherited Form" object instead of the "Windows Form" object. The wizard will ask you which form you want to base the new form on, so select the base that you previously created. When the designed opens up, you will see all of the things that you had set it the original form (and you will not be able to change them), and your new form is ready for adding controls.

            R Offline
            R Offline
            Razanust
            wrote on last edited by
            #5

            How can the objects such as texts of the labels can be made alterable in the inherited forms?

            G 1 Reply Last reply
            0
            • R Razanust

              How can i make multiple forms in a project, having the same look (background color, font etc) in VB 2008?

              J Offline
              J Offline
              Johan Hakkesteegt
              wrote on last edited by
              #6

              This article has some really good information about this subject and offers some alternatives: http://visualbasic.about.com/od/usingvbnet/l/aa081603a.htm[^]

              My advice is free, and you may get what you paid for.

              1 Reply Last reply
              0
              • R Razanust

                How can the objects such as texts of the labels can be made alterable in the inherited forms?

                G Offline
                G Offline
                Gregory Gadow
                wrote on last edited by
                #7

                It should work the same way as custom controls. When your child form is initialized, it first calls the InitializeComponent method of the form from which it is derived, which calls its ancestor's InitializeComponent, and so on. Eventually it will hit your parent form, and all of the controls will be initialized. These cascade back up as ordinary properties.

                1 Reply Last reply
                0
                • R Razanust

                  How can i make multiple forms in a project, having the same look (background color, font etc) in VB 2008?

                  D Offline
                  D Offline
                  Deep Unknown
                  wrote on last edited by
                  #8

                  well you have two ways: 1- you can create it by coding: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim SecondForm As New Form1 SecondForm.Show() End Sub in this way the button that i included has the same execution that is in the first form (it includes the same codes to execute) 2- Add new form, go to the first form and select all controls then copy and past to the new form!

                  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