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?
-Lou7 Answers, 1 is accepted
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.
Dimitar
Telerik
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
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
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
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
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
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