Multiple forms of same look.
-
How can i make multiple forms in a project, having the same look (background color, font etc) in VB 2008?
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.
-
How can i make multiple forms in a project, having the same look (background color, font etc) in VB 2008?
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
-
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
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.
-
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.
-
How can i make multiple forms in a project, having the same look (background color, font etc) in VB 2008?
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.
-
How can the objects such as texts of the labels can be made alterable in the inherited forms?
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'sInitializeComponent
, 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. -
How can i make multiple forms in a project, having the same look (background color, font etc) in VB 2008?
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!