We help IT Professionals succeed at work.
Get Started

VB.Net Form Height and Width questions

dds110 asked
Last Modified: 2008-01-09
Hi all,

I have a form that is initially displayed at 300, 300.  On the Form Load event, I'm setting the width of the rows and columns in a 4 Column X 5 Row Table Layout Panel based on the forms width and height.  Here's my code so far:

        Dim styles As TableLayoutRowStyleCollection = Me.TableLayoutPanel1.RowStyles
        For Each style As RowStyle In styles
            style.SizeType = SizeType.Absolute
            style.Height = Me.Height / 5

        Dim cols As TableLayoutColumnStyleCollection = Me.TableLayoutPanel1.ColumnStyles
        For Each col As ColumnStyle In cols
            col.SizeType = SizeType.Absolute
            col.Width = Me.Width / 4

The problem is that the Table Layout Panel always seems to be a bit larger than the actual height and width of the form.  This results in my Right-Most column and Bottom-Most Row being cut off.

What gives?

Watch Question
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE