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.
Position a control on the design surface of the Windows Forms Designer. In Visual Studio, drag the control to the appropriate location with the mouse. Select the control and move it with the ARROW keys to position it more precisely. Also, snaplines assist you in placing controls precisely on your form.
If you've already installed it and want to change the location, you must uninstall Visual Studio and then reinstall it. In the Shared components, tools, and SDKs section, select the folder where you want to store the files that are shared by side-by-side Visual Studio installations.
Control Properties Properties can be set at design time by using the Properties window or at run time by using statements in the program code. Object is the name of the object you're customizing.
Following steps are used to set the Location property of the TextBox: Step 1 : Create a textbox using the TextBox() constructor provided by the TextBox class. // Creating textbox TextBox Mytextbox = new TextBox(); Step 2 : After creating TextBox, set the Location property of the TextBox provided by the TextBox class.
You can also do it this way:
label1.Location = new Point(x,y);
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;
Setting Location.X and Location.Y will probably result in a compile-time error, because Location is of type "Point", a value type.
Just do 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 & paste.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With