Form Positioning.




I have a simple problem concerning the position of forms.

My windows form application has a main form and three instances of a
second form; BForm. It is not an MDI parent/child application and I've
set the StartPosition property for both forms to be Manual.

In the New method of the main form I create the 3 BForms and try to
position them below the main form (with the left sides aligned) using
the code below:

intPosX = 100 ' Same as the main form.
intPosY = Me.Top + Me.Height + (intBFormCounter*BForm.Height)
BForm.Location = New Point(intPosX, intPosY)

Note intBFormCounter is a zero based counter of the number of instances
of the BForm.

The three identical forms are correctly aligned and stacked but the
first (uppermost) has its title bar hidden below the lower edge of the
main form. This behaviour remains the same if I change the position of
the main form.

I think that I am not correctly determining the height or lower edge
position of the main form.

Can anyone see what I've missed?

Thanks in advance,


Ken Tucker [MVP]


You usually have to add a fudge factor when doing things like this.
Try adding 10 the y postion. Play around with it a little.



You might look at the difference between the Form size and the
Form.ClientSize heights. Note the Clientsize is the size excluding the form
title bar and borders. You may need to add this offset


Hi Ken,

Many thanks for the prompt response. A fudge factor of 19 worked for
me. I am a little surprised why this is necessary but I'm new to
VB.NET so perhaps its lack of experience ;)



Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question