in your child form
public delegate void UpdateEventHandler(object sender, EventArgs e);
public partial class KeyboardForm : Form
{
public event UpdateEventHandler UpdateParent;
public KeyboardForm()
{
InitializeComponent();
}
private void UpdateParent_Click(object sender, EventArgs e)
{
if (UpdateParent != null)
UpdateParent(this, null);
}
}
in your login form
public LoginForm()
{
InitializeComponent();
}
private void login_Click(object sender, EventArgs e)
{
KeyboardForm child = new KeyboardForm();
child.UpdateParent += new UpdateEventHandler(child_UpdateParent);
child.Show();
}
void child_UpdateParent(object sender, EventArgs e)
{
int newValue = int.Parse(textBox1.Text) +1;
textBox1.Text = newValue.ToString();
}