Results 1 to 1 of 1

Thread: [2005] Proper scaling/maximizing your forms!

  1. #1

    Thread Starter
    Addicted Member Lectere's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    222

    Thumbs up [2005] Proper scaling/maximizing your forms!

    Maybe you are familiar with these troubles: You decided to make a new application, start dropping your controls on the form and start coding. The program works fine, but then you decide to maximize your form and realize that all the controls on your form are not sizing properly.





    The solution for this is quite simple, it’s called: TableLayoutPanel.

    First thing you do is create an empty form, and drag a TableLayoutPanel on it. Make sure you have selected the TableLayoutPanel, and go to the properties. In a default setup the properties are on far right of the screen. Again, make sure you have selected the TableLayoutPanel, and change the property ‘Dock’, to the square in the centre, the value of ‘Dock’ will be ‘Fill’. Notice how the TableLayoutPanel is maximized on your current form.




    In this example we want a singleline TextBox on the upper section of our form, and a listview on the remaining lower part. Richt click on the TableLayoutPanel and select ‘Edit Rows and Columns’. Select ‘Show’, ‘Rows’. Select ‘Row1’ and on the right part, make the value, Absolute, 20. Make sure that Row2 is on Percentage, 100%.



    The next step is to drag a ‘Listview’ on the lower left square on the TableLayoutPanel. A Listview is picked in this example but, this can be anny control. Again make the ListView ‘Dock’ on the TableLayoutPanel. This is done by selecting the ListView, change its properties, and choose ‘Dock’. You will notice the ListView is docked only on the left site. To make it ‘Dock’ on both of the lower two cell’s of the TableLayoutPanel, change the property of ListView1, ‘ColumnSpan’ to 2.

    The final step is to drag a ‘TextBox’ on the upper left square of the TableLayoutPanel, again, make the TextBox Dock, ‘Fill’.

    Now to see the results, press Run/F5 and size and maximize your form!




    I often find it useful to lock the minimum size of your form, to prevent controls from diapering.

    Goodluck, happy coding!
    Attached Images Attached Images     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width