Solved

Dynamic addition of controls to a control.

Posted on 1999-01-25
3
144 Views
Last Modified: 2010-05-03
I have created a User-Defined control.  I want to add an array of standard VB Shape controls to my User-Defined control dynamically.  For example,  I want to display an array of multicolored rectangles on my User-Defined control.  I don't know how many rectangles are in the array until the user tells me.   Possible?  If so how?

0
Comment
Question by:nelchr
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
MikeP090797 earned 200 total points
ID: 1470577
Place a control named Shape1 on the usercontrol. Set its index property to 0. Then, to add a control, call Load Shape1(1), Load Shape1(2) and so on. After each call, set the .Visible property to true, and reposition the shape (or it can be any other control) using .Left and .Top properties. This is called a control array
0
 

Author Comment

by:nelchr
ID: 1470578
When I do what you suggest I get a subscript out of range on the first addition.  i.e. shape1(1) in your example.  I tried to REdim the array first to its full size but that didn't help.    It looks like you are close but ...
0
 

Author Comment

by:nelchr
ID: 1470579
ok, ok, ok  I got it.  Thanks for your help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now