Copied this answer from a previous answer I gave to the same question.
Here is the original question. There are more good answers to be found there:
How to pass the Value one form to another form in windows form[
^]
There are different ways to do this.
One is using a Property on one of your Forms.
MyForm frm = new MyForm();
frm.MyValue = "some value";
frm.Show();
Another is passing it to the constructor.
public partial class MyForm : Form
{
private String _myValue;
public Form1(String myValue)
{
InitializeComponent();
_myValue = myValue;
}
}
Usage would look like this:
MyForm frm = new MyForm("some value");
frm.Show();
Another approach could be to use a Method...
public partial class MyForm : Form
{
private String _myValue;
public void SetValue(String myValue)
{
_myValue = myValue;
}
}
Usage:
MyForm frm = new MyForm();
frm.Show();
frm.SetValue("some value");
Hope it helps! :)