Board index » delphi » Controls and their parents

Controls and their parents

A basic question this time :-) about how to find and change - at design
time - the parents of controls.

Suppose for example I have a TForm, and I put a large TScrollBox control on
it, and I put a TPanel on that.  I believe that the TForm will be the parent
of the TScrollBox, and the TScrollBox will be the parent of the TPanel, as a
consequence of where I dropped them.  This seems to be so since, if I delete
the TScrollBox, for example, the TPanel disappears too.

But is there no way to see, in print as it were, what the parent of a
control is?  When I look at my TScrollBox in the object inspector, I see no
"parent" property.  Better still would be the facility to list all the
form's components, and their parental relationships.

And then, how can I change, at design time, what the parent of a control is?
Again, there is no parent property in the object inspector, which would
enable this.  If I now realise that I didn't want that TScrollBox at all,
how can I make the TForm the parent of the TPanel, so I can get rid of the
TScrollBox without losing the TPanel?

Ciarn Duibhn.

 

Re:Controls and their parents


"Ciarn Duibhn" <cia...@oduibhin.freeserve.co.uk> wrote in message
news:88aas2$8rq$1@newsg3.svr.pol.co.uk...

Quote
> A basic question this time :-) about how to find and change - at design
> time - the parents of controls.

> Suppose for example I have a TForm, and I put a large TScrollBox control
on
> it, and I put a TPanel on that.  I believe that the TForm will be the
parent
> of the TScrollBox, and the TScrollBox will be the parent of the TPanel, as
a
> consequence of where I dropped them.  This seems to be so since, if I
delete
> the TScrollBox, for example, the TPanel disappears too.

> But is there no way to see, in print as it were, what the parent of a
> control is?  When I look at my TScrollBox in the object inspector, I see
no
> "parent" property.  Better still would be the facility to list all the
> form's components, and their parental relationships.

> And then, how can I change, at design time, what the parent of a control
is?
> Again, there is no parent property in the object inspector, which would
> enable this.  If I now realise that I didn't want that TScrollBox at all,
> how can I make the TForm the parent of the TPanel, so I can get rid of the
> TScrollBox without losing the TPanel?

Cut the tPanel and Paste it directly on the form. This will change the
tPanel's Parent appropriately. (You can then remove the tScrollBox.)

- Show quoted text -

Quote

> Ciarn Duibhn.

Re:Controls and their parents


    You can set and reset the parent property as well.  "MyObject.Parent :=
MyForm;
And you can view the dfm file as text to see what the parent currently is
and cut and paste to alter it there if you like.
Quote
"Bruce Roberts" <no.junk.please....@attcanada.net> wrote in message

news:iu3q4.25590$fy1.1918@tundra.ops.attcanada.net...
Quote

> "Ciarn Duibhn" <cia...@oduibhin.freeserve.co.uk> wrote in message
> news:88aas2$8rq$1@newsg3.svr.pol.co.uk...
> > A basic question this time :-) about how to find and change - at design
> > time - the parents of controls.

> > Suppose for example I have a TForm, and I put a large TScrollBox control
> on
> > it, and I put a TPanel on that.  I believe that the TForm will be the
> parent
> > of the TScrollBox, and the TScrollBox will be the parent of the TPanel,
as
> a
> > consequence of where I dropped them.  This seems to be so since, if I
> delete
> > the TScrollBox, for example, the TPanel disappears too.

> > But is there no way to see, in print as it were, what the parent of a
> > control is?  When I look at my TScrollBox in the object inspector, I see
> no
> > "parent" property.  Better still would be the facility to list all the
> > form's components, and their parental relationships.

> > And then, how can I change, at design time, what the parent of a control
> is?
> > Again, there is no parent property in the object inspector, which would
> > enable this.  If I now realise that I didn't want that TScrollBox at
all,
> > how can I make the TForm the parent of the TPanel, so I can get rid of
the
> > TScrollBox without losing the TPanel?

> Cut the tPanel and Paste it directly on the form. This will change the
> tPanel's Parent appropriately. (You can then remove the tScrollBox.)

> > Ciarn Duibhn.

Re:Controls and their parents


Quote
"Robert Meek" <rm...@ptd.net> wrote in message

news:s1eq4.3580$tw.72328@nnrp1.ptd.net...

Quote
>     You can set and reset the parent property as well.  "MyObject.Parent
:=
> MyForm;
> And you can view the dfm file as text to see what the parent currently is
> and cut and paste to alter it there if you like.

The parent property isn't explicitly stored in the dfm file. Rather the
structure of the dfm file indicates the parantage. I've used the technique
when trying to move a large number of components but one has to be careful.

Quote
> "Bruce Roberts" <no.junk.please....@attcanada.net> wrote in message
> news:iu3q4.25590$fy1.1918@tundra.ops.attcanada.net...

> > "Ciarn Duibhn" <cia...@oduibhin.freeserve.co.uk> wrote in message
> > news:88aas2$8rq$1@newsg3.svr.pol.co.uk...
> > > A basic question this time :-) about how to find and change - at
design
> > > time - the parents of controls.

> > > Suppose for example I have a TForm, and I put a large TScrollBox
control
> > on
> > > it, and I put a TPanel on that.  I believe that the TForm will be the
> > parent
> > > of the TScrollBox, and the TScrollBox will be the parent of the
TPanel,
> as
> > a
> > > consequence of where I dropped them.  This seems to be so since, if I
> > delete
> > > the TScrollBox, for example, the TPanel disappears too.

> > > But is there no way to see, in print as it were, what the parent of a
> > > control is?  When I look at my TScrollBox in the object inspector, I
see
> > no
> > > "parent" property.  Better still would be the facility to list all the
> > > form's components, and their parental relationships.

> > > And then, how can I change, at design time, what the parent of a
control
> > is?
> > > Again, there is no parent property in the object inspector, which
would
> > > enable this.  If I now realise that I didn't want that TScrollBox at
> all,
> > > how can I make the TForm the parent of the TPanel, so I can get rid of
> the
> > > TScrollBox without losing the TPanel?

> > Cut the tPanel and Paste it directly on the form. This will change the
> > tPanel's Parent appropriately. (You can then remove the tScrollBox.)

> > > Ciarn Duibhn.

Re:Controls and their parents


    Yes, if you get an 'end;' out of place the results can be horrendous!
But sometimes it's the ONLY way to do it. For example, yesterday I wanted to
move a component that had been dropped upon a splitter component that covers
the entire mainwindow, and move it and all it's controls intact to a Frame I
had created.  Quite often attempting to cut and paste something with more
than one control across forms will either not work or get completely screwed
up, so instead I went to the dfm file and cut and paste there.  Of course
you must then manually delete any references to it and rewrite them within
the proper units, but at least this way I'm assured it will work!

Quote
"Bruce Roberts" <no.junk.please....@attcanada.net> wrote in message

news:k_gq4.25718$fy1.1916@tundra.ops.attcanada.net...
Quote

> "Robert Meek" <rm...@ptd.net> wrote in message
> news:s1eq4.3580$tw.72328@nnrp1.ptd.net...
> >     You can set and reset the parent property as well.  "MyObject.Parent
> :=
> > MyForm;
> > And you can view the dfm file as text to see what the parent currently
is
> > and cut and paste to alter it there if you like.

> The parent property isn't explicitly stored in the dfm file. Rather the
> structure of the dfm file indicates the parantage. I've used the technique
> when trying to move a large number of components but one has to be
careful.

> > "Bruce Roberts" <no.junk.please....@attcanada.net> wrote in message
> > news:iu3q4.25590$fy1.1918@tundra.ops.attcanada.net...

> > > "Ciarn Duibhn" <cia...@oduibhin.freeserve.co.uk> wrote in message
> > > news:88aas2$8rq$1@newsg3.svr.pol.co.uk...
> > > > A basic question this time :-) about how to find and change - at
> design
> > > > time - the parents of controls.

> > > > Suppose for example I have a TForm, and I put a large TScrollBox
> control
> > > on
> > > > it, and I put a TPanel on that.  I believe that the TForm will be
the
> > > parent
> > > > of the TScrollBox, and the TScrollBox will be the parent of the
> TPanel,
> > as
> > > a
> > > > consequence of where I dropped them.  This seems to be so since, if
I
> > > delete
> > > > the TScrollBox, for example, the TPanel disappears too.

> > > > But is there no way to see, in print as it were, what the parent of
a
> > > > control is?  When I look at my TScrollBox in the object inspector, I
> see
> > > no
> > > > "parent" property.  Better still would be the facility to list all
the
> > > > form's components, and their parental relationships.

> > > > And then, how can I change, at design time, what the parent of a
> control
> > > is?
> > > > Again, there is no parent property in the object inspector, which
> would
> > > > enable this.  If I now realise that I didn't want that TScrollBox at
> > all,
> > > > how can I make the TForm the parent of the TPanel, so I can get rid
of
> > the
> > > > TScrollBox without losing the TPanel?

> > > Cut the tPanel and Paste it directly on the form. This will change the
> > > tPanel's Parent appropriately. (You can then remove the tScrollBox.)

> > > > Ciarn Duibhn.

Other Threads