I have 2 Forms in my project. Form1 is the main Form. There I have a button to open Form2, a ListView and a method to call a url and feed the ListView with data it gets from
Define a property on Form2 to allow the access of the result
// In Form2
public string Url { get { return urlTextBox.Text; } }
In Form1
var form2 = new Form2();
form2.ShowDialog(this);
string url = form2.Url;
Note: unless Show()
the ShowDialog()
method waits until form2
is closed.
The ShowDialog
argument this
is the owner of the form to be opened. It binds form2
to form1
and makes it always appear on top of form1
.