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.
 
Back
Top