Groupbox as InitialParent?


i want to use a groupbox to group several labels and textfields. in one of my windows, there is a Behavior-Option in the Inspector, to let me set the InitialParent for all my labels and textfields. There was GroutBox1 inserted automatically.

In my 2nd window, i have also a groupbox with several labels and textfields, but no option InitialParent in the Behavior-Options of these labels and textfields. So i tried to set this by this code in the open-event of my 2nd window:

txtKundenNr.Parent = GroupBox1 txtFirma.Parent = GroupBox1 txtVorname.Parent = GroupBox1 txtNachname.Parent = GroupBox1 txtTelefon.Parent = GroupBox1 txtTelefax.Parent = GroupBox1 txtEmail.Parent = GroupBox1 txtStrasse.Parent = GroupBox1 txtHausnummer.Parent = GroupBox1 txtPostleitzahl.Parent = GroupBox1 txtWohnort.Parent = GroupBox1 txtFunktion.Parent = GroupBox1

This fixed my problem by far, but it seems, that the last 4 textfields were not added completely to the groupbox. there is also no red border around the groupbox, when selecting these 4 textfields. it is, when i select any other of the textfields. when i resize the window, the groupbox resizes perfectly and all of the controls within. But when i disable the groupbox, the last 4 textfields (hausnummer, postleitzahl, wohnort, funktion) are not disabled.

Why i have to do so much coding, when my 1. windows did all this automatically?

What is the right way to add controls to a groupbox?

Drag them onto the group box on the layout in the layout editor

there is no way doing this programmatically?

This usually means that they are either not entirely within the group box, or the text fields have been placed on the window before the group box. Just grab the text fields and move them a few pixel away and back to the old position - if the red border appears, you’re all set.

ok, the new placement of these evil 4 textfields solves my problem.