I have a form (AddNewCamper), which contains a textbox and a submit button. In a different form, I’m trying to write:
if (submit button is clicked)
do stuff
In the window that the button is actually in, I have a click event created. So I guess I’m trying to call that click event inside the if statement (which is in a different window from where the click event is located).
Here’s what I have:
AddNewCamper camp = new AddNewCamper();
camp.Show();
// This is where I'm confused. How do I say if this button is clicked,
// or how do i call its click event that's located in AddNewCamper?
if (camp.btnNewSubmit_Click_1())
{
Camper person = new Camper(camp.txtNewFirstName.Text);
camp.txtNewFirstName.Text = person.getName();
c.testListBox.Items.Add(person.getName());
campersFrame.Content = c;
}
As I understand your question, seems you want to display some content in the parent form when the submit button click on the AddNewCamper Form. Below is one way that you can do that.
Add a public method to the ParentForm to Show(or refresh) the content once Submit clicked from the AddNewCamper.
In the ParentForm
Pass the ParentForm instance to the AddNewCamper Form in the contructor.
Create an AddNewCamper instance as below from the ParentForm.
Or you can set a flag in the ParentForm in the same way to identify that the Submit button is clicked.