Control.Location [英] Control.Location

查看:75
本文介绍了Control.Location的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧在框架中发现了一个我认为的错误...


有人试试这个...


Build 2表格。


在表格一中,添加一个将打开表格2的按钮。


所以


公开Class Form1

继承System.Windows.Forms.Form


...


private sub onButtonClick(发送者)作为对象,e as system.eventargs)处理

button1.click


dim f2 as new Form2

f2.Location =新点(250,250)

f2.Showdialog()

结束子


结束班

表格2上
...在你的加载活动上添加一个标签


,加上这个

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


你的坐标会说250,250,但是,你可以找到你的可能/>
不是250,250 ......

但是,如果你在表单加载上设置位置,它将起作用。所以

里面的东西重置了这个位置的价值......至少这是我一直在处理的...... / b $ b


其他人有没有这样的经历?


-CJ

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


推荐答案

*" CJ Taylor" <无**** @ blowgoats.com> scripsit:
* "CJ Taylor" <no****@blowgoats.com> scripsit:
好吧发现框架中的一个错误我认为...


我不这么认为。

构建2个表单。

在表单一中,添加一个将打开表单2的按钮。



公共类Form1
继承System.Windows.Forms.Form



私有子onButtonClick(发件人作为对象,e作为system.eventargs)处理
button1.click

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

end class <在表格2上...在你的加载事件上添加一个标签

,添加这个

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

你的coords会说250,250,但是,你可能会说你的可能
不是250,250 .. 。

但是,如果您在表单加载上设置位置,它将起作用。所以在Load中的某些东西会重置位置的价值......至少这是我一直在处理的......
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...




您确定表单''''StartPosition''属性设置为''Manual''吗?


-

Herfried K. Wagner [MVP]

< http://dotnet.mvps.org/>



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

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>


嗨CJ,


相同的行为我认为你是对的


\\

Dim f2 As New Form2

f2.Text =CJ 总是表现正确

f2.Location = New Point(250,250)

''f2.CJ = New Point(250,250)''这个有效罚款

f2.ShowDialog()

///

\\\

Public CJ As Point

Private Sub Form2_Load(ByVal sender As Object,_

ByVal e As System.EventArgs)处理MyBase.Load

''我。位置= CJ''这个工作正常

Me.Label1.Text = Me.Location.X.ToString& " " &安培; Me.Location.Y.ToString

结束子

///


但是,你会在几分钟内看到Herfried并且他有消息

已知的bug。


:-)

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


无论如何。如果您查看表格左侧和顶部属性(这将与表格中相应的X,Y道具相匹配),它会说出您输入的coordiantes

,尽管它不是表格的实际坐标。


但是,它们显然不存在。我的观点是,如果它是

StartPosition,那么它应该改变X,Y坐标,而不是仅仅在不修改这些属性的情况下绘制

表格。


2)。文档可能会更好。

" Herfried K. Wagner [MVP]" <喜*************** @ gmx.at>在留言中写道

news:c2 ************* @ ID-208219.news.uni-berlin.de ...
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.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c2*************@ID-208219.news.uni-berlin.de...
*CJ Taylor <无**** @ blowgoats.com> scripsit:
* "CJ Taylor" <no****@blowgoats.com> scripsit:
好吧发现我认为框架中存在一个错误......
Alright found a bug in the framework I think...



我不这么认为。



I don''t think so.

构建2个表单。

在表单一中,添加一个将打开表单2的按钮。



Public Class Form1
继承System.Windows.Forms.Form



私有子onButtonClick(发件人作为对象,e作为system.eventargs)
处理button1 .click

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

表2 ...在你的加载事件上加一个标签

,加上这个

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

你的坐垫会说250,250,但是,你可能会花费250美元,而不是250美元,250 ......
然而,如果您在表单加载上设置位置,它将起作用。所以在Load中的某些内容重置了该位置的价值......至少这是
我正在处理的...
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...



你是确保表单''''StartPosition''属性设置为''Manual''?

-
Herfried K. Wagner [MVP]
< http: //dotnet.mvps.org/>



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

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>



这篇关于Control.Location的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆