What is the correct way to close the parent form from a UserControl?
I created a Windows Forms application where I have a form named ShowUserControl6. Inside this form, I added a method called CloseForm to close the form. I am trying to call this method from UserControl6 using a PictureBox click event. However, when I click the PictureBox, nothing happens and the form does not close.
public void CloseForm()
{
this.Close();
}
private void pictureBox1_Click_1(object sender, EventArgs e)
{
ShowUserControl6 showUserControl6 = new ShowUserControl6();
UserControl6 control = new UserControl6();
showUserControl6.CloseForm();
}