Control.Location

C

CJ Taylor

Alright found a bug in the framework I think...

Someone try this...

Build 2 forms.

In form one, add a button that will open form 2.

so

Public Class Form1
inherits System.Windows.Forms.Form

...

private sub onButtonClick (sender as object, e as system.eventargs) handles
button1.click

dim f2 as new Form2
f2.Location = new Point(250,250)
f2.Showdialog()
end sub

end class

on form 2... add a label

on your load event, add this

me.mylabel.text = string.format ("X Coord: {0} Y Coord: {1}")

your coords will say 250,250, however, you will be able tosee your probably
not at 250, 250...

However, if you set the location on the form load, it will work. So
something in Load resets the value of the location... at least this is what
I've been dealing with...

Anywone else experience this?

-CJ
 
H

Herfried K. Wagner [MVP]

* "CJ Taylor said:
Alright found a bug in the framework I think...

I don't think so.
Build 2 forms.

In form one, add a button that will open form 2.

so

Public Class Form1
inherits System.Windows.Forms.Form

...

private sub onButtonClick (sender as object, e as system.eventargs) handles
button1.click

dim f2 as new Form2
f2.Location = new Point(250,250)
f2.Showdialog()
end sub

end class

on form 2... add a label

on your load event, add this

me.mylabel.text = string.format ("X Coord: {0} Y Coord: {1}")

your coords will say 250,250, however, you will be able tosee your probably
not at 250, 250...

However, if you set the location on the form load, it will work. So
something in Load resets the value of the location... at least this is what
I've been dealing with...

Are you sure the form's 'StartPosition' property is set to 'Manual'?
 
C

Cor

Hi CJ,

Same behaviour I think you are right

\\
Dim f2 As New Form2
f2.Text = "CJ" ' Is always showed right
f2.Location = New Point(250, 250)
' f2.CJ = New Point(250, 250) ' This works fine
f2.ShowDialog()
///
\\\
Public CJ As Point
Private Sub Form2_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
' Me.Location = CJ ' this works fine
Me.Label1.Text = Me.Location.X.ToString & " " & Me.Location.Y.ToString
End Sub
///

However, you will see in some minutes comes Herfried and he has the message
"known bug".

:)

Cor
 
C

Cor

Hi Herfried,
\\\
Dim f2 As New Form2
f2.Text = "CJ"
f2.StartPosition = FormStartPosition.Manual
f2.Location = New Point(250, 250)
' f2.CJ = New Point(250, 250) ' This works fine
f2.ShowDialog()
///

Yes works also
Are you sure the form's 'StartPosition' property is set to 'Manual'?

Why should you do that, do you have documentation?

Cor
 
C

CJ Taylor

Regardless. If you look at the forms Left and Top Properties (which will
match the corresponding X,Y props of the form) it will say the coordiantes
you entered, although its not the actual coordinates of the form.

However, they obviously aren't there. My point being, if its the
StartPosition, then it should change the X,Y coords and not just draw the
form without modifying those properties.

2). Documentation could be better.
 
H

Herfried K. Wagner [MVP]

* "Cor said:
\\\
Dim f2 As New Form2
f2.Text = "CJ"
f2.StartPosition = FormStartPosition.Manual
f2.Location = New Point(250, 250)
' f2.CJ = New Point(250, 250) ' This works fine
f2.ShowDialog()
///

Yes works also


Why should you do that, do you have documentation?

If you don't set it, Windows will determine the position used to show
the form even if you set the position.
 
H

Herfried K. Wagner [MVP]

* "CJ Taylor said:
Regardless. If you look at the forms Left and Top Properties (which will
match the corresponding X,Y props of the form) it will say the coordiantes
you entered, although its not the actual coordinates of the form.

However, they obviously aren't there. My point being, if its the
StartPosition, then it should change the X,Y coords and not just draw the
form without modifying those properties.

ACK.
 
C

CJ Taylor

So am I right or wrong?

Herfried K. Wagner said:
If you don't set it, Windows will determine the position used to show
the form even if you set the position.
 

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

Top