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

Keep raddock toolwindows equal size when resizing application window

3 Answers 242 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Susan
Top achievements
Rank 1
Susan asked on 26 Oct 2017, 06:16 PM
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?

3 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 31 Oct 2017, 12:51 PM
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.
0
Amit
Top achievements
Rank 1
answered on 06 Sep 2019, 05:04 AM

I have a Raddock containing Documentcontainer, RadSplitWindow and many TooltabStrip. On a button click I want make equal size of windows.

With above code this is not possible as windows in same column should be considered as one.

Please how can i give equal width to all windows?

 

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 06 Sep 2019, 08:54 AM

Hello, Amit,    

According to the provided screenshot, it seems that two of the ToolWindows are arranged vertically. This will calculate wrong width per window since these two windows share the same width but their height is twice smaller. There is not automatic API for handling this case and to be honest it wouldn't b easy at all to determine this.

Note that RadDock is actually a derivative of RadSplitContainer which hosts all windows in split panels. The split panel that contains the two vertically oriented ToolWindows actually contains another nested RadSplitContainer which contains two items in the Controls collection. Knowing this arrangement of the panels, you may iterate the RadDock.SplitPanels collection recursively in depth and see if there are any nested RadSplitContainers that host more than one ToolWindow. In general, to calculate the proper width per window, you need to know the total width of RadDock and the number of ToolWindows among which you need to distribute the width. 

However, have in mind that it would probably require a lot of conditions and checks for the windows arrangement and after moving a window or redocking it to a new place, new split panels will be created in RadDock to host the window at its new position. This is a quite complex layout and it is performed over the current size of RadDock. That is why I would suggest you to think about the SplitPanelSizeMode.Relative where you can specify RelativeRatio. Then, whenever the size of RadDock changes, you can reset the sizing mode and assign a new ratio in order to calculate automatically the size. Additional information is available in the following help article: https://docs.telerik.com/devtools/winforms/controls/dock/object-model/example-building-an-advanced-layout-at-runtime

I hope this information helps.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Susan
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Amit
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or