/// <summary>Called when the Cancel button is clicked. If the event is not canceled and the parent control is a form, /// the form will be closed with <see cref="DialogResult.Cancel"/>. /// </summary> protected virtual void OnCancelButtonClicked(CancelEventArgs e) { if(CurrentStepIndex != -1) CurrentStep.OnCancelButtonClicked(e); if(CancelButtonClicked != null) CancelButtonClicked(this, e); if(!e.Cancel && !DesignMode) // don't close the form in design mode { Form form = Parent as Form; if(form != null) { form.DialogResult = DialogResult.Cancel; if(!form.Modal) form.Close(); } } }