Library tutorials & articles
Planning Form Layout in VB.NET
- Introduction
- Getting Started
- Building the form
- The problem
- The solution
Building the form
So let us go ahead building the form shown above. First of all we need to add three panels, which will resize in different ways.
Change the 'BackColor' properties of the panels as shown above so that it is easier to differentiate the panels. You can set it back to its default color once you are done.
Now first dock the Red panel (assuming that you have used the same colors) to the bottom of the form, next dock the Green panel to the left and lastly dock the Blue panel to the center to fill up rest of the area. Note that it is important you do the docking in the same order mentioned above; else you will not get the desired layout. Save your work and run the application, you will see that the panels are getting resized as you resize the form. Next you can go ahead and put in all controls as shown below.
Now let us start anchoring controls within the panels. Starting with the Green panel, (you can start with any of them.) we would want all the dropdown controls in the green panel to maintain the same constant distance from the top, left and right edges of the panel, and also expand horizontally as the form/panel expands.
Select all the dropdown controls in the green panel by holding down the 'Ctrl' key and clicking on each of them with the mouse. Now in the properties window, dropdown the anchor property and anchor the selected controls to Top, Left, and Right as shown below.
Note: you are not selecting the bottom anchor since you do not want the controls to expand vertically when the form is resized vertically.
Related articles
Related discussion
-
Error in VB code
by glib162002 (0 replies)
-
i have struck with my project in vb.net
by gangireddysaritha (1 replies)
-
Very slow inserts using SqlCommand.ExecuteNonQuery()
by porchelvi (1 replies)
-
Datagridview Setting datasource property of datagridviewcomboboxcell at run time
by sairfan1 (2 replies)
-
vb.net mp3 +g player
by novavb6 (1 replies)
Related jobs
-
Microsoft .Net Architect
in AMSTERDAM (€50K-€90K per annum)
Events coming up
-
Dec
6
Developing AJAX Web Applications with Castle Monorail
London, United Kingdom
Monorail is the model-view-controller engine of the Castle Project, bringing many of the best ideas of Ruby on Rails to the .NET world. In this talk, David De Florinier and Gojko Adzic show how Monorail makes it easy to develop .NET based AJAX applications, and how to use the Castle Project to build Web 2.0 applications effectively. Come to this session if you are a .NET web developer. Everyone is welcome!
It is difficult to design fairly complicated forms by simply using anchors and docks. .Net provides two layout manager Flow layout panel and Table Layout Panel. However you need to use a good layout manager for professional form designing, e.g. SmartLayouts .
I would use 4 panels in the following way:
1) one up (this is the extra panel that is not in your example). Set the Dock property to this one to Top and set the Height to whatever you want.
2) The Green panel will be inside the panel one. Set the Dock property to Left and set the Width to whatever you want
3) The Bleu panel also inside the panel one. Set the Dock property to Fill.
4) The fourth panel (the Red one) comes bottom (as child of the form) with Dock set to Fill. (this is also a difference to your example)
The rest of the things are the same.
What we have accomplished with the fourth panel ? The fact that the Height of the Blue/Green panels is fixed to the height of the Panel One, so no coding is necessary to keep the height fix.
The only problem left is that the Width of the Green panel is fixed and when the form is made wider it does not resize. So the only code necesary is to make the
Green panel wider according with the width of the form.
Best regards,
Dan
good work - and helpful!
Good one ! Keep it up ...
This is very very very nice
[6]keep it up[/6]
good work
This thread is for discussions of Planning Form Layout in VB.NET.