Tab closing -> back to TabStrip

9 posts, 0 answers
  1. Marc
    Marc avatar
    8 posts
    Member since:
    Mar 2017

    Posted 02 May Link to this post

    Hey,

    I'm using the dock.
    It is possible to move tabs out of the TabStrip.

    If a user press the close-Button on the tab, I want to dock the tab back to the DocumentTabStrip.

    How can I do this?

     

    Regards, Marc

  2. Dimitar
    Admin
    Dimitar avatar
    1871 posts

    Posted 02 May Link to this post

    Hello Marc,

    You can use the DockWindowClosing event to achieve this:
    private void RadDock1_DockWindowClosing(object sender, Telerik.WinControls.UI.Docking.DockWindowCancelEventArgs e)
    {
        if (e.NewWindow.Text == "documentWindow1")
        {
            e.Cancel = true;
            e.NewWindow.DockState = Telerik.WinControls.UI.Docking.DockState.TabbedDocument;
        }
    }

    I hope this will be useful.

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Marc
    Marc avatar
    8 posts
    Member since:
    Mar 2017

    Posted 02 May Link to this post

    Hey Dimitar,

    this is perfect! Thank you!

    Is there any solution for redock at the same position as docked before?

     

    Regards, Marc

  4. Dimitar
    Admin
    Dimitar avatar
    1871 posts

    Posted 02 May Link to this post

    Hello Marc,

    An example for this is available here Set order to document windows - Dock - UI for WinForms Forum.

    I hope this helps.

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Bruce
    Bruce avatar
    25 posts
    Member since:
    May 2017

    Posted 05 Jul in reply to Dimitar Link to this post

    Dimitar said:Hello Marc,

    You can use the DockWindowClosing event to achieve this:
    private void RadDock1_DockWindowClosing(object sender, Telerik.WinControls.UI.Docking.DockWindowCancelEventArgs e)
    {
        if (e.NewWindow.Text == "documentWindow1")
        {
            e.Cancel = true;
            e.NewWindow.DockState = Telerik.WinControls.UI.Docking.DockState.TabbedDocument;
        }
    }

    I hope this will be useful.

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.

     

    In the example above,when using auto MDI, the dock tab doesn't close, but the form inside is closed, leaving a blank tab, is there a method to prevent the form from closing also.

  6. Dimitar
    Admin
    Dimitar avatar
    1871 posts

    Posted 06 Jul Link to this post

    Hello Bruce,

    The MDI child forms are explicitly closed in our code. In this case, you can use the Closing event of the child form:
    private void radButton1_Click(object sender, EventArgs e)
    {
        var childForm = new RadForm2();
        childForm.Text = "MDI Child " + DateTime.Now.ToShortTimeString();
        childForm.MdiParent = this;
     
        childForm.FormClosing += ChildForm_FormClosing;
        childForm.Show();
    }
     
    private void ChildForm_FormClosing(object sender, FormClosingEventArgs e)
    {
        e.Cancel = true;
        var form = sender as RadForm2;
        var host = form.Parent as HostWindow;
        host.DockState = DockState.TabbedDocument;
    }

    I hope this will be useful. 

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  7. Bruce
    Bruce avatar
    25 posts
    Member since:
    May 2017

    Posted 07 Jul in reply to Dimitar Link to this post

    Thank you for your Reply, this prevents the child form from closing in all circumstances, not just when someone attempts to close the tabbed document hosting it. 

    How would you in the closing event of the child form identify that the call to closed originated from the tabbed document, and not all instances? 
  8. Dimitar
    Admin
    Dimitar avatar
    1871 posts

    Posted 11 Jul Link to this post

    Hi Bruce,

    You can check the DockState of the window:
    private void ChildForm_FormClosing(object sender, FormClosingEventArgs e)
    {
        var form = sender as RadForm2;
     
        var host = form.Parent as HostWindow;
        if (host.DockState == DockState.Floating)
        {
            host.DockState = DockState.TabbedDocument;
            e.Cancel = true;
        }
    }

    Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  9. Bruce
    Bruce avatar
    25 posts
    Member since:
    May 2017

    Posted 11 Jul in reply to Dimitar Link to this post

    This worked Great, Thanks Dimitar! 
Back to Top