How to return to the calling method after calling a windows Form in c#?

Viewed 275

I have a method, where I call a new Windows Form in Class A. And in the new Form, I use a Dropdown menu and store the selected Item from the Dropdown in a variable, called selectedItem.Now I have to access this selectedItem in Class A. I use the following code.

public class A
{
    public method callingmethod()
    {
        ExceptionForm expform = new ExceptionForm();
        expform.Show();
        string newexp = expobj.selectedexception;
    }
}

And my code in New Form,

public partial class ExceptionForm : Form
{
    public string selectedexception = string.Empty;
    private void btnExpSubmit_Click(object sender, EventArgs e)
    {
        selectedexception = this.comboBox1.GetItemText(this.comboBox1.SelectedItem);
        this.Close();
        return;
    }
}

Now After clicking on Submit button, I get the correct value in selectedItem, But I could not pass it to Class A. How to retun to Class A?

2 Answers
Related