Link to home
Start Free TrialLog in
Avatar of sshayevich
sshayevich

asked on

Putting controls on form

I need to put some controls on form in Visual Basic at run time. How do I do it?
Avatar of jjmartin
jjmartin

Add the first control, and give it an index of zero. (i.e. cmdTest(0)

Then, at runtime you can use the load method to load a new control:

Load cmdTest(1)

Then you have to postion it (it is loaded in exactly the same postion as the control with an index of zero) and set the visible property to true in order to see it.
ASKER CERTIFIED SOLUTION
Avatar of Ruchi
Ruchi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
At design time give the control an index of 0 so as to create a control array. Then when you want to load a new instance of it, do it like this:

Textbox for example

Load Text(1)
geez i type slow
place all the controls you need on your form when building it an put the visible property at false then at run time change the visible at true for the control you need to use
gfaucher...the question was how to add controls at run time.
Avatar of sshayevich

ASKER

When I try to add a new control to controls collection of the form, I don't get a list of properties and methods where I can pull the Add method from. Any idea why?
if youre talking about the convenient popup menus that appear when you normally type in comments like text1.text (when you type the "."), that won't appear when referencing the control collection of the form. However it doesnt mean its not working.  It should still run fine.
Thank you!