DockWindow contents disappear on confirm closing

4 posts, 1 answers
  1. Sergi
    Sergi avatar
    34 posts
    Member since:
    Sep 2007

    Posted 22 Jun 2011 Link to this post

    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.
  2. Sergi
    Sergi avatar
    34 posts
    Member since:
    Sep 2007

    Posted 22 Jun 2011 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Answer
    Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 22 Jun 2011 Link to this post

    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.
  5. Sergi
    Sergi avatar
    34 posts
    Member since:
    Sep 2007

    Posted 23 Jun 2011 Link to this post

    Thanks, I thought it was counterintuive that it works that way, but now I see the adventages of closing from inside out.
Back to Top