Disabling the close button of the toolwindow

12 posts, 0 answers
  1. Llorens Mathieu
    Llorens Mathieu avatar
    19 posts
    Member since:
    Jan 2009

    Posted 10 Dec 2009 Link to this post

    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
  2. Georgi
    Admin
    Georgi avatar
    296 posts

    Posted 11 Dec 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Llorens Mathieu
    Llorens Mathieu avatar
    19 posts
    Member since:
    Jan 2009

    Posted 16 Dec 2009 Link to this post

    Thanks for your reply. Is it possible to disable the contextual menu ? Because when I click on Hide" the toolwindow disappear.

    Thank you.
  5. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 16 Dec 2009 Link to this post

    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.
  6. Abhishek
    Abhishek avatar
    3 posts
    Member since:
    Apr 2011

    Posted 05 May 2011 Link to this post

    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);

     

     



  7. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 11 May 2011 Link to this post

    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.
  8. Abhay
    Abhay avatar
    11 posts
    Member since:
    Jan 2011

    Posted 13 May 2011 Link to this post

    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
  9. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 18 May 2011 Link to this post

    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.
  10. Abhay
    Abhay avatar
    11 posts
    Member since:
    Jan 2011

    Posted 01 Jun 2011 Link to this post

    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

  11. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 06 Jun 2011 Link to this post

    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.
  12. Abhay
    Abhay avatar
    11 posts
    Member since:
    Jan 2011

    Posted 06 Jun 2011 Link to this post

    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
  13. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 09 Jun 2011 Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready