在执行 VB.NET 时更改按钮的位置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22659888/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change location of buttons at execution VB.NET
提问by user3463961
I am trying to change the location and size of buttons I have contained in a panel on a WinForm (vb.NET). Initially the buttons have a location and an image (no text), but in execution I want to set a new location and text. I am able to set the text for each button, and as they are set to Autosize, they increase in width. But despite I set the location by code correctly, when the buttons are displayed they "come back" to their initial position.
我正在尝试更改 WinForm (vb.NET) 面板中包含的按钮的位置和大小。最初按钮有一个位置和一个图像(无文本),但在执行时我想设置一个新的位置和文本。我可以为每个按钮设置文本,并且当它们设置为 Autosize 时,它们的宽度会增加。但是,尽管我通过代码正确设置了位置,但当显示按钮时,它们“返回”到初始位置。
Any help would be appreciated.
任何帮助,将不胜感激。
Thanks,
谢谢,
IM
我是
回答by James
The following code will change the location to the co-ordinates you specify:
以下代码会将位置更改为您指定的坐标:
Button1.Location = New Point(x, y)
You must change the x,y values to the co-ordinates on the form that you want to move the button too.
您也必须将 x,y 值更改为要移动按钮的表单上的坐标。
The next bit of code with change the size of your button:
下一段更改按钮大小的代码:
Button1.Height = 10
Button1.Width = 50

