Get comboBox value from another form in C#

I have 2 forms, in Form1 there is a button which will show Form2. in Form2 i have a comboBox. After selecting an item from comboBox, user can click Button to send a comboBox value to Form1 and Form2 will close.

Here my code:

Form1:

private void Button1_Click(object sender, EventArgs e)
{
    Form2 frm2 = new Form2();
    frm2.ShowDialog();
}

Form2:

private void Button1_Click(object sender, EventArgs e)
{
    Form1 frm1 = new Form1();
    frm1.textBox1.Text = Convert.ToString(comboBox1.SelectedValue);

    this.DialogResult = DialogResult.OK;
}

But i the comboBox value doesn’t appear at textBox on Form1saas


Source: forms

Leave a Reply