Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Poss. to find out Child controls from the Parent?

Status
Not open for further replies.

LucieLastic

Programmer
May 9, 2001
1,694
GB
hi

I have a form created at runtime. Combos are added (at runtime) to the form depending of whats required.

The form is then 'assigned' to a TabSheet by setting it's Parent := tabsheet.

In my interface, there's a copy button and all I know is the Parent tabsheet. I want to be able to get all the child controls on the tabsheet and copy their information to a new form containing a new tabsheet. Also, the owner of all the controls is a datamodule.

Components and ComponentCount don't work as Tabsheet comes up as having 0 components, I think because all the controls I want are overlayed on a form.

Is it possible?

One more question, is is possible to sendMessage to a Datamodule as a datamodule doesn't have a handle?

lou
 
Could you loop through the components on the form, and then check to see who the parent is?

For i := 0 to Form1.ComponentCount - 1 do
begin
if Form1.Components.Parent = Tabsheet then
begin
CopyToOtherForm(NewForm,Form1.Components);
end;
end;

Or could you use the tag property and synchronize the tag of the child properties with a tag you assign to a tabsheet?

Brian
 
hi Brian

Thanks for the reply. I now have it working. I had to set the Owner of the overlay form to be the tabsheet - I was under the impression that setting the Parent to be the tabsheet would have been sufficient.

thanks again
lou
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top