Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
225
Setting DockAreaPane Height
posted

DockAreaPane.Size is relative to other DockAreaPanes' size in the same DockArea.

I have the previous Height of a group of DockAreaPanes in the same DockArea. I want to set to those panes back to these previous size. But, I can't set the height exactly the size that I want. Is there a formula to set the Height to what I want?

Parents
No Data
Reply
  • 44743
    posted

    To determine the absolute sizes, the relative sizes are totaled and then divided evenly across the available with or height. So let's say you have two groups stacked vertically which are docked on the left side of the Form and there is 100 pixels of height in the Client area of the Form. The top group has a Size with 200 for the height and the bottom group has a Size with 100 pixels for the height. So there is a total of 300 units for the height to be distributed across 100 pixels. So every 3 units for the height would correspond to one pixel. Therefore, the top group would be 67 pixels tall and the bottom group would be 33 (they would actually be slightly less because some space is removed for the splitter between them).

    So now let's say the Form size is changed and there is 200 pixels of client area and you want the top group to only occupy 50 pixels. You can calculate what it's Size's height should be based on the bottom group's Height.

    FH (Form Height) = 200
    TRH (top group relative height) = ?
    BRH (bottom group relative height) = 100
    TAH (top group absolute height = 50
    BAH (bottom group absolute height) = ?

    First, we have to determine the bottom group's absolute height. Obviously, the sum of both group heights equals the total Form height:
    BAH + TAH = FH
    If we subtract TAH from both sides, we get
    BAH = FH - TAH
    BAH = 200 - 50
    BAH = 150

    Then, since we know the relative heights relate directly to the absolute heights, we can say
    TRH / TAH = BRH / BAH
    If we multiple each side by TAH, we get
    TRH = TAH * (BRH / BAH)
    TRH = 50 * (100 / 150)
    TRH = 33

    So the height you assign to the top group would be 33.

Children