471,090 Members | 1,277 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,090 software developers and data experts.

how to set form startup location/position manually?

I am instnatiating a second form from a first form. I set startuplocation to
manual, then I enter 100 for X and 300 for Y on the second form. Then on the
click event of a button on form1 I have Dim frm = New form2, frm.Show. But
form2 shows up way to the right of the screen. I also tried this in code

frm.Location = New Point(100, 300)

but same results. How do you control the position of a form in VB.Net?

Thanks,
Rich
Nov 21 '05 #1
3 95106
"Rich" <Ri**@discussions.microsoft.com> schrieb:
I am instnatiating a second form from a first form. I set startuplocation
to
manual, then I enter 100 for X and 300 for Y on the second form. Then on
the
click event of a button on form1 I have Dim frm = New form2, frm.Show.
But
form2 shows up way to the right of the screen.


Make sure the form's 'StartPosition' property is set to 'Manual'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
Rich wrote:
I am instnatiating a second form from a first form. I set startuplocation to
manual, then I enter 100 for X and 300 for Y on the second form. Then on the
click event of a button on form1 I have Dim frm = New form2, frm.Show. But
form2 shows up way to the right of the screen. I also tried this in code

frm.Location = New Point(100, 300)

but same results. How do you control the position of a form in VB.Net?

Thanks,
Rich


Here is an example which might help...The child form is positioned in
relations to a CheckBox on the calling form. So no matter were the user moves
the form it is always were it should be in relation to the caller.

Dim f As New frmYourForm
Try
With f
.RunCode = True
.Location = Me.PointToScreen(New Point(CheckBox1.Left, CheckBox1.
Top + CheckBox1.Height))
.ShowDialog(Me)
End With
Finally
f.Dispose()
End Try

--
kevinDotSDotGallagherAtstateDotOrDotUs
Nov 21 '05 #3
Thank you all for your replies. I am setting StartPosition to Manual, and I
have tried the suggestions, but my form is still not behaving as desired. I
don't know if the following makes a difference, but the second form is
actually an indipendent form - not a child form (of an mdi form). One thing
I just noticed is this - if I set the startposition to CenterScreen or
CenterParent - the second form is not behaving as expected. The property is
being ignored. I only have 2 forms, so it is not like I am picking the wrong
form. If I set the primary form to CenterScreen - it appears on CenterScreen
as expected, but the second form does not behave as expected. Is there a
property I need to set/unset perhaps?

Thanks,
Rich

"Rich" wrote:
I am instnatiating a second form from a first form. I set startuplocation to
manual, then I enter 100 for X and 300 for Y on the second form. Then on the
click event of a button on form1 I have Dim frm = New form2, frm.Show. But
form2 shows up way to the right of the screen. I also tried this in code

frm.Location = New Point(100, 300)

but same results. How do you control the position of a form in VB.Net?

Thanks,
Rich

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by lauren quantrell | last post: by
2 posts views Thread by Geoff Jones | last post: by
2 posts views Thread by Daniel | last post: by
3 posts views Thread by Rich Wallace | last post: by
2 posts views Thread by Tharpa Roberts | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.