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
-
How to write a query set to excel using vb.net
by BarbaMariolino (1 replies)
-
Very Urgent regarding deleting the images from a folder
by rameshbandi (2 replies)
-
Block Accessing MSSQL 2000
by militia (0 replies)
-
.NET Developer in Ghana Required....
by sysview (0 replies)
-
Sending SMS to mobile using secure gateway from VB.net 2008 c#
by pratikasthana17 (0 replies)
Related podcasts
-
xpert to Expert: Inside Concurrent Basic (CB)
"Concurrent Basic extends Visual Basic with stylish asynchronous concurrency constructs derived from the join calculus. Our design advances earlier MSRC work on Polyphonic C#, Comega and the Joins Library. Unlike its C# based predecessors, CB adopts a simple event-like syntax familiar to VB progr...
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.