Library tutorials & articles
Planning Form Layout in VB.NET
The problem
Let the labels remain anchored to their default values Top, Left. Which means they will maintain a constant distance from the top and left edges of the form/panel.
Do the same thing for the blue panel. The red panel needs to behave a little differently. The textbox (set Multiline property of the textbox to True) needs to expand both horizontally as well as vertically when the form expands. So set the anchor property of the textbox to all four direction Top, Bottom, Left, and Right.
Anchor the label 'Remarks:' only to left, so that it sticks to the left edge and also repositions itself vertically at proportional distances from the top and bottom edges of the panel.
Next the two buttons 'Save' and 'Cancel' needs to be anchored to the bottom-right corner as shown below.
Now go ahead now, save your work and hit F5. You see that the controls are getting resized along with the form. Bingo!!! , You did all this without writing a single line of code. Now see what happens when you maximize the form… Hey! Wait a minute; this is not exactly what we wanted….
What exactly is happening here is that, the blue and the green panels are not resizing horizontally in equal proportion. Since the green panel is set to dock to the left and the blue panel is set to fill up the remaining horizontal area, we see that this is exactly what is happening. The same thing is happening to the red panel as well, it is docking itself to the bottom and the other two panels are taking up the rest of the space 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.