Forum > Designer

GroupBox question - Component Z order - I need a little help/advice.

(1/2) > >>

Yukiko:
I am not "new" to Lazarus and Pascal but I am trying to make a program I have wrote some time ago a little nicer looking. Parts of the interface have controls which probably should be grouped together for esthetics if not practicality from a UI standpoint. This program was written in my early days with Lazarus so I was not very adventurous with the design phase. As such I never used TGroupBox.

Here's my problem: I add an empty GroupBox to a tab on my form and move existing components on to it by selecting them and dragging them onto it. Then I set the Z-order of the GroupBox by sending it to the back so as to make my newly added components visible. This works for all of the components except the labels. They are not visible. I can select a label if I click on the empty space where is should be displayed but nothing I do, ie. setting its Z-order to front etc., seems to make it visible. Since these are just labels I can delete the old ones and recreate new ones on the GroupBox but then I do not get the alignment lines when trying to align the labels with the other components in the box.

I have "wised up" and now and place the group box first before adding components. That I assume is the "preferred" way of doing it. Unfortunately that does not help me with the older parts of the interface for which I would like to have in a group box.

Does anyone have any advice that can help me here?

Handoko:

--- Quote from: Yukiko on October 07, 2018, 12:19:18 pm ---This works for all of the components except the labels.

--- End quote ---

Maybe you should use TStaticText, which can be found in the Additional tab.

Yukiko:
I will give that a try. Thank you Handoko. I'll let you know if it works for having the "alignment" lines appear as they should.

wp:

--- Quote from: Yukiko on October 07, 2018, 12:19:18 pm ---I add an empty GroupBox to a tab on my form and move existing components on to it by selecting them and dragging them onto it. Then I set the Z-order of the GroupBox by sending it to the back so as to make my newly added components visible.

--- End quote ---
If I understand correctly you drag the controls in the *Form Designer* into the GroupBox? This does not work, the controls do not become children of the Groupbox this way. You can see this when you drag the GroupBox to another place - do the controls follow? If not I am right and you should continue reading.

There are two ways (maybe more) how to bring the controls into the GroupBox:

* Right-click on the control to be moved into the GroupBox. In the context menu there is a "Change Parent". Select the Groupbox in the list and click OK.
* Select the node of the control in the ObjectTree above the Object Inspector and drag it immediately below the Groupbox node - there is an insertion line when the location is correct.In both cases, it may happen that the control is not visible any more. This is because its coordinates (left, top) are not changed but are considered to be relative to the GroupBox. Thus, if the control was located at 0, 400, and the groupbox is only 200 pixels high the control will be beyond the lower end of the groupbox. With the control selected (or select its node in the Object Tree), set its property "Top" to some value within the GroupBox (0 is always correct) and then drag it to its final location. The same, of course, with "Left".

If you now drag the Groupbox to another location, the control will follow.

Yukiko:
@Handoko - With static text I still do not get the form alkignment lines.

Thanks wp. I will give that one a go. I keep forgetting the "parent -> child relationship" of components. I bet that is the problem.


--- Quote from: wp on October 07, 2018, 12:45:21 pm ---In both cases, it may happen that the control is not visible any more. This is because its coordinates (left, top) are not changed but are considered to be relative to the GroupBox. Thus, if the control was located at 0, 400, and the groupbox is only 200 pixels high the control will be beyond the lower end of the groupbox. With the control selected (or select its node in the Object Tree), set its property "Top" to some value within the GroupBox (0 is always correct) and then drag it to its final location. The same, of course, with "Left".

--- End quote ---

Will this be the case even if I resize the GroupBox to a size that would encompass the components prior to changing their parentage?

Navigation

[0] Message Index

[#] Next page

Go to full version