Close all tabs at once instead of just one?

8 posts, 0 answers
  1. Lou
    Lou avatar
    61 posts
    Member since:
    Aug 2014

    Posted 15 May 2015 Link to this post

    Hi, I would like to change the behavior of a RadDock far-right-hand-side close ('x') button (on the top right of the DocumentTabStrip) to close all of the opened tab windows instead of just the current window. On the screen shot, it's the red 'x' on the top right that I'm talking about.

    How would I do this?

     -Lou
  2. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 18 May 2015 Link to this post

    Hello Lou,

    Thank you for writing.

    You can use the DockWindowClosed event and close all document windows. The event will be triggered when one of the windows is closed:
    void radDock1_DockWindowClosed(object sender, DockWindowEventArgs e)
    {
        if (e.DockWindow is DocumentWindow)
        {
            radDock1.CloseWindows(radDock1.DockWindows.DocumentWindows);
        }
         
    }

    In addition you can use the context menu to close windows (see attached image).

    Let me know if you have additional questions.
     
    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Lou
    Lou avatar
    61 posts
    Member since:
    Aug 2014

    Posted 18 May 2015 in reply to Dimitar Link to this post

    Thanks for the reply Dimitar.

    Also thanks for letting me know about the "close" and "close all" context menu, I didn't know about that. I might decide to just use this existing functionality instead of trying to modify the default behavior (it it proves too difficult).

    In any case - the code that you supplied is not quite doing what I want. I only want to close all of the windows if the user clicked on the close button ('x') that is located on the top right of RadDock.

    The method you suggest seems to close all of the windows, whenever any window is closed.

    -Lou

     

  5. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 19 May 2015 Link to this post

    Hello Lou,

    Thank you for writing back.

    What you can do is to use the MouseClick event of the DocumentTabStrip. This way you can check if the close button is clicked and close the windows:
    void radDock1_DockWindowAdded(object sender, DockWindowEventArgs e)
    {
        if (e.DockWindow is DocumentWindow)
        {
            DocumentTabStrip strip = e.DockWindow.DockTabStrip as DocumentTabStrip;
            strip.MouseClick += strip_MouseClick;
        }
    }
     
    void strip_MouseClick(object sender, MouseEventArgs e)
    {
        DocumentTabStrip strip = sender as DocumentTabStrip;
        var clickedElemnt = strip.ElementTree.GetElementAtPoint(e.Location) as RadButtonElement ;
        if (clickedElemnt != null && !(clickedElemnt is TabStripButtonItem))
        {
            radDock1.CloseWindows(radDock1.DockWindows.DocumentWindows);
        }
    }

    Let me know if you have additional questions.

    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Lou
    Lou avatar
    61 posts
    Member since:
    Aug 2014

    Posted 19 May 2015 in reply to Dimitar Link to this post

    Thanks Dimitar. For now I went with using the context menu "close all" functionality since it's simple and available already. If I need to get the top right button working I will try out your suggestion.

     -Lou

  7. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 20 May 2015 Link to this post

    Hi Lou,

    Thank you for writing back.

    I just want to mention that additional information about the context menu is available at the end of the following article: Understanding RadDock.

    Do not hesitate to contact us if you have other questions.

    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  8. Lou
    Lou avatar
    61 posts
    Member since:
    Aug 2014

    Posted 20 May 2015 in reply to Dimitar Link to this post

    Hi Dimitar, thanks for the link to that article, it was helpful. The links to the two videos on that page ( http://tv.telerik.com/winforms/raddock/introducing-new-raddock-winforms and http://tv.telerik.com/winforms/raddock/getting-started-with-raddock-winforms ) didn't take me to the correct videos though. It redirected to a general video page (http://www.telerik.com/videos ) and I wasn't able to view the RadDock videos as I couldn't find them. If you have the correct links for those two videos would you let me know? Thanks,

     -Lou

  9. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 21 May 2015 Link to this post

    Hi Lou,

    Thank you for writing back.

    The videos are currently being transferred from the old site (tv.telerik.com) to www.telerik.com/videos. Please note that this process is not finished yet and there maybe be issues with the videos' links for the next few days. Until this is resolved you can view all videos for WinForms in this page.

    I hope this will be useful.

    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WinForms is Visual Studio 2017 Ready