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

Close all tabs at once instead of just one?

7 Answers 357 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Lou
Top achievements
Rank 1
Lou asked on 15 May 2015, 10:01 PM

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

7 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 18 May 2015, 03:15 PM
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
0
Lou
Top achievements
Rank 1
answered on 18 May 2015, 07:17 PM

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

 

0
Dimitar
Telerik team
answered on 19 May 2015, 11:33 AM
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
0
Lou
Top achievements
Rank 1
answered on 19 May 2015, 01:18 PM

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

0
Dimitar
Telerik team
answered on 20 May 2015, 08:58 AM
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
0
Lou
Top achievements
Rank 1
answered on 20 May 2015, 01:50 PM

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

0
Dimitar
Telerik team
answered on 21 May 2015, 07:34 AM
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
Tags
Dock
Asked by
Lou
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Lou
Top achievements
Rank 1
Share this question
or