Dynamically set the parent of a newly created control

  • Thread starter Thread starter Lou
  • Start date Start date
L

Lou

How, after dynamically creating a new button control, set it's parent to a
panel control
This doesn't seem to work:
NewButton.Parent-MyPanelControl

-Lou
 
Lou said:
How, after dynamically creating a new button control, set it's parent to a
panel control

[Just about] Every Control can contain other Controls, so you need to do
this the other way around:

MyPanelControl.Controls.Add( newButton )

If in doubt about stuff like this, have a rummage through the "Designer
Generated" code for a crash course in how to construct forms in code...
;-)

HTH,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top