Help: Dynamically add/remove controls? 
Author Message
 Help: Dynamically add/remove controls?

In Visual Basic 5.0, is it possible to add/remove controls (list box,
radio button, text box, etc.) to a form during run time? Also, can the
modified form be saved back to the original form or save as a new form?

Thank a lot for anyone who can help.

algae



Sat, 18 Mar 2000 03:00:00 GMT  
 Help: Dynamically add/remove controls?

Quote:

> In Visual Basic 5.0, is it possible to add/remove controls (list box,
> radio button, text box, etc.) to a form during run time? Also, can the

Yes. Look at New and at Load as pertains to control arrays.

Quote:
> modified form be saved back to the original form or save as a new form?

Not unless you do the legwork yourself by storing the properties of the
new and modified controls in a file or database! The OCX's that claim to
do this never seem to do quite what you want.

[snip]

--
Joe Foster <mailto:joe*AT*bftsi0.gate.net> Spam is irrelevant.
WARNING: I cannot be held responsible for the above        They're   coming  to
because  my cats have  apparently  learned to type.        take me away, ha ha!



Sat, 18 Mar 2000 03:00:00 GMT  
 Help: Dynamically add/remove controls?

Search for help on the Load statement.

I do not believe you can save the newly created form though.
--
Lance King
Work: 770-801-4502

Take out "nos.pam." to send message.



Quote:
> In Visual Basic 5.0, is it possible to add/remove controls (list box,
> radio button, text box, etc.) to a form during run time? Also, can the
> modified form be saved back to the original form or save as a new form?

> Thank a lot for anyone who can help.

> algae



Sat, 18 Mar 2000 03:00:00 GMT  
 Help: Dynamically add/remove controls?

I recently had this same question. The easiest way to create controls at
run time is with a control array. Create a control and place it on your
form. Set it's index property to 0. (This tells VB that this part of a
control array even though the array now has only one element.) You can even
set the control's visible property to False.

Let's suppose that the controls you want to create are Command Buttons.
Let's call them cmdTest.

Now, in a procedure in your form you can use the following to create
controls at runtime.

Dim lngIndex as Long
lngIndex = lngIndex + 1
Load cmdTest(lngIndex)

The load command will create a new copy of the control each time you
execute the load command. The index property has to increment so you get
new controls.

Also, don't forget on each new control to set the appropriate properties
such as:

.Top
.Left
.Height
.Width

I hope this helps.

Regards,

Anthony Gatlin



Quote:
> In Visual Basic 5.0, is it possible to add/remove controls (list box,
> radio button, text box, etc.) to a form during run time? Also, can the
> modified form be saved back to the original form or save as a new form?



Sat, 18 Mar 2000 03:00:00 GMT  
 Help: Dynamically add/remove controls?



Quote:
> In Visual Basic 5.0, is it possible to add/remove controls (list box,
> radio button, text box, etc.) to a form during run time?

Yes.

Quote:
>Also, can the modified form be saved back to the original form or
>saved as a new form?

No.

John Morrison



Sat, 18 Mar 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Help: Dynamically add/remove controls?

2. Need to remove dynamically added controls?

3. Best practises for dynamically adding and removing event handlers

4. Removing entries from Add/Remove list in control panel

5. Adding Events to Dynamically Added Controls

6. HELP! Adding controls dynamically

7. Help! Adding controls dynamically

8. Need help dynamically adding ActiveX controls to an MDI child window

9. Dynamically create (and remove) controls

10. Dynamically adding controls to the Controls collection

11. Dynamically add controls to a control array

12. create/remove controls dynamically at run-time

 

 
Powered by phpBB® Forum Software