On Form1 I have 2 textboxes, I want to edit the Form2’s location with those. (textbox1 = X, textbox2 = Y)
Thank you very much!
Here is the codes I have done:
private void button8_Click(object sender, EventArgs e)
{
frm2 = new Form2();
frm2.Top = int.Parse(textBox2.Text);
frm2.Left = int.Parse(textBox3.Text);
}
It isnt working, I think I should create a method in form2 ? sorry for my ignorance
Every Form-Object has properties to define its position and dimension on screen.
Referring to the MSDN documentation http://msdn.microsoft.com/en-us/library/system.windows.forms.form.aspx these properties are
int Form.Top(Gets or sets the distance, in pixels, between the top edge of the control and the top edge of its container’s client area.)int Form.Left(Gets or sets the distance, in pixels, between the left edge of the control and the left edge of its container’s client area.)int Form.Width(Gets or sets the width of the control.)int Form.Height(Gets or sets the height of the control.)Assuming you have two form-objects named form1 and form2 and you want to modify the properties of form2 by inputing values in textfields that are on form1 you simply have to do something similar to:
Be aware that you want to pass integer values (numbers) to the properties of form2 but the
string TextBox.Textproperty is of type string. You might want to apply a cast from string to int which is the default way to do it – as it is shown above by using