Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 153
  • Last Modified:

Creating new controls on the fly (VB6)

I have an application that needs to create new controls on the fly (a label control and button to be precise). Is this possible?

rd707

0
rd707
Asked:
rd707
1 Solution
 
iozturkCommented:
Best approach may be create one with index property set to 0 then  use the code something like

Load Label1(i)
Label1(i).Caption = "Set Caption"
Label1(i).Top = Label1(i-1).Top + 200
Label1(i).Visible = True
0
 
IeuanJCommented:
Most cant be created as new in the strictest sense.  For example you cannot simply create a new label.  Iozturk has already mentioned the solution I use to get around this, simply create one indexed instance of the object as design time and then create more instances later.

Just be careful to unload them when finished as they tend to casue major memory usage if you dont.
0
 
QJohnsonCommented:
Labels don't need code behind them, so you can just add as many to the projects as you want with the .Add method of the Controls collection.

Buttons aren't much use without code, though.  So the control array techinque that is being suggested above is your best bet for those.  
0
 
CleanupPingCommented:
Hi rd707,
This old question (QID 20568715) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now