0

How do i pass data from a form i opened in userControl back to the userControl? userControl code:

 public AdminControl()
    {
        InitializeComponent();
        SetGridColomns();
    }
 private void btnEditInfo_Click(object sender, EventArgs e)
    {
        Form editForm = new EditForm();

        if (editForm.ShowDialog() == DialogResult.OK)
        {
        // trying to get Owner2 here but failing
        }
    }

Form Code:

 public partial class EditForm : Form
{

    public CompanyOwner Owner2;
    public EditForm()
    {
        InitializeComponent();
        Owner2 = new CompanyOwner();

    }
    private void btnSave_Click(object sender, EventArgs e)
    {
        Owner2.Address = tbAddress.Text;
        Owner2.CompanyName = tbCompanyName.Text;
        Owner2.Email = tbEmail.Text;
        Owner2.Phone = tbPhone.Text;
    }
}

When i try to get editForm.Owner2 nothing shows up. I tried making it static, using strings instead of class and still nothing. Where im going wrong?

0

1 Answer 1

2

Nvm i find the mistake ... i should use EditForm instead of Form:

EditForm editForm = new EditForm();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.