I got some probs with the close button on my form. it used to be set as cancel button of the form, but I change it to none. The form works like guide…
I want to popup yes-no-messagebox if the form is in some step of guide. But with code I have now it is closing the form whatever I click yes or no.
Code of button:
if (krok <= 5)
{
if (MessageBox.Show("este ste neurobili vsetko naozaj chcete zavriet okno?",
"Pozor",
MessageBoxButtons.YesNo,
MessageBoxIcon.Warning) == DialogResult.Yes)
{
Close();
}
}
else Close();
Every button has a property called
DialogResult. You can set this property directly in the designer window or in the code. The effect of this property is to close the form and (if the form is shown modally) return the value of the property to the form calling code.In your case, I suspect that this property is set (in designer window) to something different from
DialogResult.None. If this is the case then your form will close whater you call Close() or not.