Changing the location of a windowed control using VB.net?

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

+6
source share
4 answers

What are you trying? I believe that the easiest way is to set the โ€œUpโ€ and โ€œLeftโ€ properties individually:

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

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

+15
source share

You can also do it like this:

 label1.Location = new Point(x,y); 
+19
source share

Just do it like this.

 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Label1.Location = New Point(50, 70) End Sub 

Yes, just copy and paste.

+1
source share

If I want to read the location on a TextBox in a Windows form (here IC_View_Config), it works to find find the value of X. But for some reason I can not get it to work on the value of Y! Is this a known bug or am I a โ€œbugโ€?

TextBox5.Text = IC_View_Config.Textbox1.Location.X (working fine)

TextBox6.Text = IC_View_Config.Textbox1.Location.Y (I cannot get it to work)

in

0
source share

All Articles