How can I delete DialogResult object ? I am using it as a confirmation for clearing form (removing all controls and reinitializing of controls). The problem is that when I hit yes it recreates the second DialogResult, then third one, then fourth, etc.
SO when user hits yes, I would like to remove this DialogResult. Is there a way?
Code here:
private void GUI_DCP_FormClosing(object sender, FormClosingEventArgs e)
{
var confirmation_text = "If you click 'Yes', all information will be discarded and form reset. If you want to save the input click 'No' and then 'Save'";
DialogResult dialogResult = MessageBox.Show(confirmation_text, "WARNING", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
this.Hide();
e.Cancel = true; // this cancels the close event.
this.Controls.Clear();
this.InitializeComponent();
this.Height = 278;
this.Width = 341;
}
else
{
e.Cancel = true;
}
}