[英]how to change the location of controls in TableLayoutPanel control at runtime in vb.net windows form
[英]Changing the location of a control on a windows form programatically using VB.net?
單擊Button1時,我需要將label1的位置屬性從(50,50)更改為(50,70)。 這應該很容易,但是我無法使其正常工作。
您也可以這樣操作:
label1.Location = new Point(x,y);
你在想什么 我發現最簡單的方法是分別設置Top和Left屬性:
label1.Left = 50;
label1.Top = 70;
設置Location.X和Location.Y可能會導致編譯時錯誤,因為Location的類型為“ Point”(值類型)。
就這樣吧
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Label1.Location = New Point(50, 70)
End Sub
是的,只需復制並粘貼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.