例如一个Button控件你要让它永远居中:可以在form 的resize事件中写代码来实现:
button.left=(form.width)/2-(button.width)/2+form.left
button.top=(form.height)/2-(button.height)/2+form.top
button.left=(form.width)/2-(button.width)/2+form.left
button.top=(form.height)/2-(button.height)/2+form.top
否则不在最中间
特别是设置了ScaleMode属性后
button.left=(form.scalewidth-button.width)\2
button.top=(form.scaleheight-button.height)\2
cmdTest.Move (Me.ScaleWidth - cmdTest.Width) \ 2, (Me.ScaleHeight - cmdTest.Height) \ 2
如果有多个控件,放在容器里,让容器居中就OK!
button.Left = (Me.Width) / 2 - (button.Width) / 2 + Me.Left
button.Top = (Me.Height) / 2 - (button.Height) / 2 + Me.Top
这样的结果就是button 是在From 处于最大化的状态下居中.
他不是随着我From的大小而改变位置..
上面说的问题没有了..还是很想知道根据坐标如何设置