Best way is to have an event in the child form which the parent form subscribes too for updating controls on the parent form from the child form.
In this case, the main form is MainForm and the child form name is Child Form. The ChildForm has a NumericUpDownControl to control the value from the MainForm named numericUpDown1. I added a label too to show other controls can be used also.
These are for passing the value back to MainForm
public delegate void OnPassingNumber(int value);
public event OnPassingNumber PassingNumber;
Complete Child Form
public partial class ChildForm : Form
{
public delegate void OnPassingNumber(int value);
public event OnPassingNumber PassingNumber;
public ChildForm()
{
InitializeComponent();
}
public ChildForm(int value)
{
InitializeComponent();
numericUpDown1.Value = value;
}
private void PassDataButton_Click(object sender, EventArgs e)
{
PassingNumber?.Invoke((int)numericUpDown1.Value);
}
}
MainForm
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
numericUpDown1.Value = 10;
label1.DataBindings.Add("Text", numericUpDown1, "Value");
}
private void ShowChildButton_Click(object sender, EventArgs e)
{
ChildForm childForm = new ChildForm((int)numericUpDown1.Value);
childForm.PassingNumber += ChildFormOnPassingNumber;
try
{
childForm.ShowDialog();
}
finally
{
childForm.Dispose();
}
}
private void ChildFormOnPassingNumber(int value)
{
numericUpDown1.Value = value;
}
}