Connecting Tech Pros Worldwide Forums | Help | Site Map

how to set form startup location/position manually?

Rich
Guest
 
Posts: n/a
#1: Nov 21 '05
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

Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
#2: Nov 21 '05

re: how to set form startup location/position manually?


"Rich" <Rich@discussions.microsoft.com> schrieb:[color=blue]
>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.[/color]

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/>

Kevin G via DotNetMonster.com
Guest
 
Posts: n/a
#3: Nov 21 '05

re: how to set form startup location/position manually?


Rich wrote:[color=blue]
>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[/color]

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
Rich
Guest
 
Posts: n/a
#4: Nov 21 '05

re: how to set form startup location/position manually?


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:
[color=blue]
> 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[/color]
Closed Thread


Similar Visual Basic .NET bytes