PDA

View Full Version : Adding controls to a form at runtime



xltrader100
05-20-2009, 08:47 PM
I have Userform1 which contains Frame1 which contains MultiPage1, and on Page4 is Frame2 which contains Frame3. Frame3.Left is 100 and Frame3.Top is 200. If Frame3 wasn't there and I wanted to add it at runtime, what's the syntax that would do it for me? What if I didn't know the names of Frame3's parents?

Bob Phillips
05-21-2009, 01:19 AM
We say this over and over again, but it really is not a good idea to add controls at runtime. Far better to add it at design time, making it visible/not visible as required.

xltrader100
05-21-2009, 06:58 AM
I agree, but this is a special case. So, are you saying it can't be done?

Bob Phillips
05-21-2009, 08:17 AM
No, just that you shouldn't, even for special cases. Adding the control is trivial, but you also have to add an event handler.

xltrader100
05-21-2009, 08:38 AM
Well, maybe you could help out with the trivial part and just tell me what the syntax is to add the control.