This is a migrated thread and some comments may be shown as answers.

DockWindow contents disappear on confirm closing

3 Answers 80 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Sergi
Top achievements
Rank 1
Sergi asked on 22 Jun 2011, 02:52 PM
I want to add a confirm dialog when a user tries do close a dockwindow, I'm using the raddock as a mdicontainer, I use the DockWindowClosing event:

private void radDock1_DockWindowClosing(object sender, DockWindowCancelEventArgs e)
{
  if (RadMessageBox.Show("Are you sure", "Confirm", MessageBoxButtons.YesNo, RadMessageIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.No) {
      e.Cancel = true;
  }
}

The problem is that when I call RadMessageBox.Show, all the contents of the radwindow disappear.

How can I fix this so that I can ask for confirmation when closing a raddock window?

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Sergi
Top achievements
Rank 1
answered on 22 Jun 2011, 03:02 PM
I know why it fails, the mdi form that is the content of the radwindow gets closed even before the dialog is shown.

I think it's a bug because even if I cancel the event the mdi form gets closed.

Any help on how to fix it?

Thanks in advance.
0
Accepted
Nikolay
Telerik team
answered on 22 Jun 2011, 05:13 PM
Hello Sergi,

Thank you for your question.

The closing events are fired in the following order:

FormClosing of the form
FormClosed of the form
DockWindowClosing of the DockWindow that hosts your form
DockWindowClosed of the DockWindow that hosts your form.

So, in order to achieve your scenario, you should implement your logic in the FormClosing event handler of the form.

I hope that this information helps. If you have additional questions, feel free to contact me.

Greetings,
Nikolay
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
0
Sergi
Top achievements
Rank 1
answered on 23 Jun 2011, 11:15 AM
Thanks, I thought it was counterintuive that it works that way, but now I see the adventages of closing from inside out.
Tags
Dock
Asked by
Sergi
Top achievements
Rank 1
Answers by
Sergi
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or