Keep raddock toolwindows equal size when resizing application window

2 posts, 0 answers
  1. Susan
    Susan avatar
    8 posts
    Member since:
    Jun 2014

    Posted 26 Oct 2017 Link to this post

    I have 3 vertical tool windows inside a dock that fills the window.  I have all set as relative sizing. It works great when I resize smaller.  When I increase the application window size, the tool windows do not increase in width.  How can I fill the dock window when I enlarge?
  2. Hristo
    Admin
    Hristo avatar
    1440 posts

    Posted 31 Oct 2017 Link to this post

    Hi Susan,

    Thank you for writing.

    This behavior is not directly supported. However, you can accomplish your task by using an Absolute size mode for each of the tool windows. A similar approach is demonstrated here: https://docs.telerik.com/devtools/winforms/dock/object-model/example-building-an-advanced-layout-at-runtime.

    Please also check my code snippet below: 
    public partial class Form1 : Form
    {
        Size currentSize;
     
        public Form1()
        {
            InitializeComponent();
     
            this.radDock1.SizeChanged += RadDock1_SizeChanged;
        }
     
        private void RadDock1_SizeChanged(object sender, EventArgs e)
        {
            int width = this.radDock1.Width - this.currentSize.Width;
            var windows = this.radDock1.GetWindows<ToolWindow>();
            if (width % windows.Count() == 0)
            {
                int x = width / windows.Count();
                foreach (ToolWindow tw in windows)
                {
                    tw.TabStrip.SizeInfo.AbsoluteSize = new Size(tw.TabStrip.SizeInfo.AbsoluteSize.Width + x, tw.TabStrip.SizeInfo.AbsoluteSize.Height);
                }
     
                this.currentSize = this.radDock1.Size;
            }
        }
         
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);
     
            this.currentSize = this.radDock1.Size;
     
            foreach (ToolWindow tw in this.radDock1.GetWindows<ToolWindow>())
            {
                tw.TabStrip.SizeInfo.SizeMode = SplitPanelSizeMode.Absolute;
            }
        }
    }

    Bear in mind that with this approach you will be solely responsible for the sizes of the tool windows. You can further extend it to suit best your actual setup. I am also attaching a short video showing the result on my end.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top