Library tutorials & articles

Planning Form Layout in VB.NET

Getting Started

Let's delve in and find out. We will start out by designing the user interface shown below of my new experimental application -'An expense tracker'. (My 'Guinea pig' to learn dot net technology)

Now when it came to resizing controls first I started experimenting with the anchor and dock properties, but what the hell? Controls would either overlap or move away to opposite extremes of the form, or get jumbled up. Tried all possible stunts to no avail. If you set the anchor property, the dock property would vanish and vice versa. The controls never seemed to care about each other; all that they were concerned was either to stick to an edge of the form or to maintain a constant distance from the edges of the form.

During this process, I observed that there were controls, which could be grouped together, which needed to resize in the same way. This observation finally led me to the idea of using panels to group those controls, and did need to use a little code to get the desired effect. :(

But here is the good news; it is definitely a lot easier than resizing controls in VB6. I still got away writing just a couple of lines of code.

Comments

  1. 01 Sep 2008 at 12:58

    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 .

  2. 28 Oct 2003 at 05:21

    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

  3. 15 Dec 2002 at 07:55

    good work - and helpful!

  4. 07 Mar 2002 at 23:58


    Good one ! Keep it up ...

  5. 07 Mar 2002 at 03:05

    This is very very very nice


    [6]keep it up[/6]


    good work


  6. 01 Jan 1999 at 00:00

    This thread is for discussions of Planning Form Layout in VB.NET.

Leave a comment

Sign in or Join us (it's free).

AddThis

Related jobs

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!