使用 VB.net 以编程方式更改 Windows 窗体上控件的位置? [英] Changing the location of a control on a windows form programatically using VB.net?

查看:41
本文介绍了使用 VB.net 以编程方式更改 Windows 窗体上控件的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在单击 Button1 时将 label1 的位置属性从 (50, 50) 更改为 (50, 70).这应该很容易,但我无法让它工作.

I need to change the location property of label1 from (50, 50) to (50, 70) when Button1 is clicked. This should be easy, but I can't get it to work.

推荐答案

你在尝试什么?我发现最简单的方法是单独设置 Top 和 Left 属性:

What are you trying? I find the easiest thing to do is set the Top and Left properties individually:

label1.Left = 50;
label1.Top = 70;

设置 Location.X 和 Location.Y 可能会导致编译时错误,因为 Location 是Point"类型,值类型.

Setting Location.X and Location.Y will probably result in a compile-time error, because Location is of type "Point", a value type.

这篇关于使用 VB.net 以编程方式更改 Windows 窗体上控件的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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