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

Disabling the close button of the toolwindow

11 Answers 517 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Llorens Mathieu
Top achievements
Rank 1
Llorens Mathieu asked on 10 Dec 2009, 04:14 PM
I have an application with a toolwindow on the left and i'd like to disable the close button. Is it possible to do this?
Or is it possible to cancel the event ?

Thank you

11 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 11 Dec 2009, 07:35 AM
Hi Llorens

Thank you for contacting us.

Yes, you have complete control on that button's visibility. Each DockWindow instance exposes a ToolCaptionButtons property, which defines what buttons are displayed on the hosting ToolTabStrip for that window. So, you may do the following:

this.toolWindow1.ToolCaptionButtons &= ~ToolStripCaptionButtons.Close;

 I hope this helps. Do not hesitate to contact us if you have other questions.


Kind regards,
Georgi
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Llorens Mathieu
Top achievements
Rank 1
answered on 16 Dec 2009, 04:56 PM
Thanks for your reply. Is it possible to disable the contextual menu ? Because when I click on Hide" the toolwindow disappear.

Thank you.
0
Nikolay
Telerik team
answered on 16 Dec 2009, 05:19 PM
Hello Llorens Mathieu,

Please refer to this forum thread which explains how you can modify the context menu.

If you have additional questions, feel free to contact me.

Kind regards,

Nikolay
the Telerik team

 


Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Abhishek
Top achievements
Rank 1
answered on 05 May 2011, 07:30 AM
Hi,

I am currently evaluating Q1 - 2011 version of RadControls and was trying to remove / hide the close button from a toolwindow, but I am afraid the solution provided above doesn't work for me.
this.toolWindow1.ToolCaptionButtons &= ~ToolStripCaptionButtons.Close;

Here goes my toolwindow creation code, where I am setting this property.

 

ToolWindow tw = new ToolWindow (); 

 

 

//tw.DocumentButtons &= ~DocumentStripButtons.Close; //tried this as well

 

tw.ToolCaptionButtons &= ~ToolStripCaptionButtons.Close; 

 

 

dockMgr.AddDocument(tw); 

 

dockMgr.FloatWindow(tw);

 

 



0
Nikolay
Telerik team
answered on 11 May 2011, 08:29 AM
Hi Llorens,

Thank you for writing.

If you add a ToolWindow as a tabbed document, you should use the following code snippet:

ToolWindow tw = new ToolWindow();
tw.DocumentButtons &= ~DocumentStripButtons.Close;
this.radDock1.AddDocument(tw);

Further, if you dock a ToolWindow as a tool window, you should use the following code snippet:
ToolWindow tw = new ToolWindow();
tw.ToolCaptionButtons &= ~ToolStripCaptionButtons.Close;
this.radDock1.DockWindow(tw, DockPosition.Left);

Please find attached screenshots which demonstrates how these code snippets work.
  
If you want to remove the close button of the floating window as well, you can do it as it is shown below:
public Form1()
{
    InitializeComponent();
 
    this.radDock1.FloatingWindowCreated += new FloatingWindowEventHandler(radDock1_FloatingWindowCreated);
 
    ToolWindow tw = new ToolWindow();           
    this.radDock1.FloatWindow(tw);
}
 
void radDock1_FloatingWindowCreated(object sender, FloatingWindowEventArgs e)
{
    e.Window.FormElement.TitleBar.CloseButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
}

I hope this helps.

Kind regards,
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.
0
Abhay
Top achievements
Rank 1
answered on 13 May 2011, 10:15 PM
Hi Nikolay.

Your proposed code change works very well to hide the close button off the floating window.

But as it is obvious that making this code change would hide the close button for ALL the dockable windows when they are made floating. This is because FloatingWindowCreated event is raised on RadDock instead of DockWindow.

My question is that is it possible to control the visibility of close button on floating windows individually per window?

As an illustration, let's suppose that my DockingManager has two dockable windows DW1 and DW2. I want DW1 to display the Close button when floating where as it should be hidden for DW2 when DW2's DockState is changed to Floating.

I hope I've made myself clear.

~Abhay
0
Stefan
Telerik team
answered on 18 May 2011, 04:57 PM
Hello Abhay,

Thank you for writing.

You can achieve the desired behavior by handling the FloatingWindowCreated event. You should check which is the ActiveWindow of RadDock. Here is an example where the close button of toolWindow1 will not be visible:

void radDock1_FloatingWindowCreated(object sender, FloatingWindowEventArgs e)
{
    if (radDock1.ActiveWindow == toolWindow1)
    {
        e.Window.FormElement.TitleBar.CloseButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
    }
}

I hope this helps. Should you have any other questions, do not hesitate to contact us.
 
Best wishes,
Stefan
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.
0
Abhay
Top achievements
Rank 1
answered on 01 Jun 2011, 07:18 PM
Hello Stefan.

The ability to get the active window does enable me to control the visibility of Close button on floating windows individually.

Thanks.
~Abhay

0
Stefan
Telerik team
answered on 06 Jun 2011, 01:55 PM
Hello Abhay,

Thank you for writing back.

I am not sure I understand your last reply.  Could you please confirm that everything is working OK now, or provide me with information about the scenarios that are not met yet. 

I am looking forward to your reply.
 
Regards,
Stefan
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.
0
Abhay
Top achievements
Rank 1
answered on 06 Jun 2011, 05:31 PM
Hello Stefan.

I realize that my reply seemed inconclusive. But my intention was to say that your suggested solution did solve my problem.

Thanks.
~Abhay
0
Stefan
Telerik team
answered on 09 Jun 2011, 09:09 AM
Hello Abhay,

I am glad to hear that. Should you have any other questions, do not hesitate to contact us.
 
Greetings,
Stefan
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.
Tags
Dock
Asked by
Llorens Mathieu
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Llorens Mathieu
Top achievements
Rank 1
Nikolay
Telerik team
Abhishek
Top achievements
Rank 1
Abhay
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or