Hiding ToolWindow toolbar?

12 posts, 0 answers
  1. Glenn
    Glenn avatar
    11 posts
    Member since:
    Oct 2012

    Posted 21 Nov 2012 Link to this post

    I have set my Docking.ToolWindow.Text to nothing and the ToolCaptionButtons to None. How can I hide the toolbar altogether? Ideally I would like to be able to programmatically make it reappear on mouse over. Is there a property for this somewhere?

    Thanks,

    G
  2. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 21 Nov 2012 Link to this post

    Hi Glenn,

    You need to set the CaptionVisible property of the desired ToolTabStrip to false as described in this article:

    this.toolTabStrip1.CaptionVisible = false;

    However, I am not sure which part of RadDock you would then like to hover in order to make the caption appear again as the caption would not be available for hover operations at that time. In addition, when you place controls in the ToolWindow, they will start receiving the MouseOver event, so no such events will be processed to the underlying RadDock windows. Let me know if I have misunderstood your requirement, so that I can provide you with an adequate response.

    Greetings,
    Nikolay
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Glenn
    Glenn avatar
    11 posts
    Member since:
    Oct 2012

    Posted 21 Nov 2012 Link to this post

    Thanks. This works great. For my purposes, the ToolWindow MouseEnter and MouseLeave work well for handling visibility of the caption. There is a little bit of a trick to detecting if the leave is to move to the caption bar and not hide then, but not so bad.

    Thanks a bunch for taking the time to help me out.

    G
  5. Glenn
    Glenn avatar
    11 posts
    Member since:
    Oct 2012

    Posted 26 Nov 2012 Link to this post

    Nikolay,

    Interestingly, this.toolTabStrip1.CaptionVisible = false does not seem to work once the toolwindow has been undocked and redocked again. Is this a bug or a feature?

    Thanks,

    G
  6. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 27 Nov 2012 Link to this post

    Hello Glenn,

    No, this is not an issue in RadDock. RadDock dynamically creates ToolTabStrips to host the ToolWindows that you are dragging. Since the ToolTabStrip instance that you get after redocking the window is new, it is not aware of the CaptionVIsible setting. Therefore, you need to handle the DockTabStripNeeded event, which is fired when RadDock needs to create a ToolTabStrip, and set the property for the newly created strip as well like so:

    void radDock1_DockTabStripNeeded(object sender, Telerik.WinControls.UI.Docking.DockTabStripNeededEventArgs e)
    {
        ToolTabStrip strip = new ToolTabStrip();
        strip.CaptionVisible = false;
        e.Strip = strip;
    }

    I hope this helps. Greetings,
    Nikolay
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  7. Glenn
    Glenn avatar
    11 posts
    Member since:
    Oct 2012

    Posted 27 Nov 2012 Link to this post

    I've tried out your example with mixed results. Perhaps I should explain a little better.

    I have derived my own class from ToolTabStrip. It has an MouseEnter event that shows the caption bar and a MouseLeave event that hides it.

    As suggested, I  created the following code:

    private void _uxRadDock_DockTabStripNeeded(object sender, DockTabStripNeededEventArgs e)
            {

                MyToolTabStrip strip = new MyToolTabStrip();
                strip.CaptionVisible = true;
                e.Strip = strip;
            }

    This does hide the caption as desired when the MouseLeave event fires and sets the CaptionVisible=false. But now when the MouseEnter event fires and sets CaptionVisible=true nothing happens. The captions is permanently set to not show. There is still something broken. Now instead of not showing the caption, it hides the caption once I leave (as it should) but doesn't show it again on enter (as it should).

    Thanks,

  8. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 28 Nov 2012 Link to this post

    Hello Glenn,

    I was not able to reproduce the described behavior. Please find attached a sample project which follows your scenario. As you can see there, the caption is set to visible and then hidden as expected. If your case is different, please open a new support ticket and send a sample project where that will demonstrate your whole scenario. This will allow me to provide you with a more adequate response.

    Kind regards,
    Nikolay
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  9. Glenn
    Glenn avatar
    11 posts
    Member since:
    Oct 2012

    Posted 29 Nov 2012 Link to this post

    I think I understand what is happening now. The difference between your sample and my code is that I'm subscribing the derived ToolTabStrip to the MouseEnter event of the ToolWindow. That way, when the mouse enters the ToolWindow the caption bar will appear. I'm showing video in the ToolWindow and want all the realistate possible, but when the mouse enters I want to show the user that they can undock.

    Anyhow, when I redock the same ToolWindow is kept so it is firing to the event handler on the old TabStrip....which is not being garbage collected because of the event that has not been unsubscribed. 

    So, what I really need to do is unsubscribe the old TabStrip from the ToolWindow.OnMouseEnter event and subscribe the new TabStrip to it. 

    Once DockTabStripNeeded is called, is it possible for me to get a reference to the proper ToolWindow so I can subscribe to this event? And is it possible to get a reference to the old TabStrip to unsubscribe it? Or can I possibly tell it to use the old TabStrip, since it's obviously still around trying to handle events as is evidenced by my debugger?

    Part of the challenge is that when the DockTabStripNeeded event fires, I don't know what TabStrip it is firing for, otherwise I could just create my own structure for referencing these objects and wire up and dispose of them as needed. 

    Is there anything obvious I'm missing?

    Thanks,

    G
  10. Glenn
    Glenn avatar
    11 posts
    Member since:
    Oct 2012

    Posted 30 Nov 2012 Link to this post

    I ended up finding a simple solution in the ToolTabStrip.ControlAdded event. From here I can detect if the control being added is a ToolWindow, then unwire the event subscription from this object to the old ToolTabStrip, then wire up the new event handler.

    Everything now works exactly as I envisioned.

    Thanks,

    G
  11. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 30 Nov 2012 Link to this post

    Hello Glenn,

    I am glad that everything is working as expected for you now. Just as a tip, another approach that you can follow is to unsubscribe from the events in the body of the ToolTabStrip descendant itself in the overridden Dispose method:

    public class MyToolTabStrip : ToolTabStrip
    {
        public MyToolTabStrip()
        {
            WireEvents();
        }
     
        void MyToolTabStrip_MouseLeave(object sender, EventArgs e)
        {
            this.CaptionVisible = false;
        }
     
        void MyToolTabStrip_MouseEnter(object sender, EventArgs e)
        {
            this.CaptionVisible = true;
        }
     
        void WireEvents()
        {
            this.MouseEnter += new EventHandler(MyToolTabStrip_MouseEnter);
            this.MouseLeave += new EventHandler(MyToolTabStrip_MouseLeave);
        }
     
        void UnwireEvents()
        {
            this.MouseEnter += new EventHandler(MyToolTabStrip_MouseEnter);
            this.MouseLeave += new EventHandler(MyToolTabStrip_MouseLeave);
        }
     
        protected override void Dispose(bool disposing)
        {
            UnwireEvents();
            base.Dispose(disposing);
        }
    }

    I hope this helps.

    All the best,
    Nikolay
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  12. Peter
    Peter avatar
    4 posts
    Member since:
    Aug 2016

    Posted 13 Aug in reply to Nikolay Link to this post

    Hi Nikolay,

    Is it possible to hide the icon when I drag the ToolWindow control from docking?(when it becomes a Form,there will be a default icon shown)

    Regards

    Peter

  13. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 15 Aug Link to this post

    Hello Peter,

    Thank you for writing. 

    In order to hide the icon of the floating form, it is necessary to handle the RadDock.FloatingWindowCreated event and set the FloatingWindowEventArgs.Window.ShowIcon property to false:
    private void radDock1_FloatingWindowCreated(object sender, Telerik.WinControls.UI.Docking.FloatingWindowEventArgs e)
    {
        e.Window.ShowIcon = false;
    }

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready