How to use two TSplitter with different aligns (Horizontal and Vertical)?

10,442

Solution 1

The extra Panel is the right way. Trying to have 2 Splitters inside one ClientArea is just overtaxing the Alignment system. Besides, the cost of an extra TPanel is very low.

Solution 2

Place 2 controls. For example 2 richedit: - Put both the controls over the same panel. - the left one with property 'align' to 'aleft' - the right one with property 'align' to 'alclient' !!! - then place the splitter in-between. - the splitter is aligned to alLeft.

For a horizontal splitter change splitter align property to 'altop'.

Share:
10,442
Lepidosteus
Author by

Lepidosteus

French developer

Updated on July 05, 2022

Comments

  • Lepidosteus
    Lepidosteus over 1 year

    I have a form with three sections, and I want to allow the users to resize them as they please

    There is one section on the left (which take the whole height) and one on the right that is again cut in two vertically. See below:

    11|22
    11|---
    11|33

    Using one splitter is quite easy:

    Component1.align := alLeft
    Splitter1.align := alLeft
    Component2.align := alClient

    Now, starting with that I have absolutely no idea how to get a vertical splitter working. If I set my second splitter to alTop or alBottom, it does all the way to the top/bottom and not only in the right half.

    I manage to get something like this:

    11111
    --------
    22||33

    By creating the vertical split first, and then the horizontal one, but that doesn't work the other way.

    One possible solution is to use a panel as my right side and then use a splitter INSIDE this pannel for vertical splitting but it doesn't really feels like the right way.

    Thanks

  • Toby Allen
    Toby Allen over 14 years
    Yes when you need anything complex with splitters, Tpanel's are the way to go
  • skamradt
    skamradt over 11 years
    You can also easily set the BevelOuter to bvNone and the panel no will no longer have a border.
  • Mawg says reinstate Monica
    Mawg says reinstate Monica over 6 years
    Just curious, why Tpanel and not TGroupbox?
  • Henk Holterman
    Henk Holterman over 6 years
    A GroupBox is a TPanel with a header. If you don't need/want the header ...