?
Solved

Need to Programmatically add a UserControl onto my UserControl

Posted on 2003-03-12
5
Medium Priority
?
171 Views
Last Modified: 2010-04-07
I'm using VB 6.0, and created an ActiveX Control Project.  My main control (.ctl) which was created along with my Project needs to be able to dynamically/programmatically place within it another control (.ctl) which I created as an User Control in the same project.  Let's say I have a "UserControl1.ctl" as the main, and a "UserControl2.ctl" as a control that is placed on the first.  The method I tried just to get it declared was:

''''(UserControl1)(Code)''''''

Private m_abc As UserControl2

Private Sub Initialize()
  Set m_abc = New UserControl2
End Sub

''''''''''End code''''''''''

You can do the above for a form, but when it comes to a control, I can't do a "Set".  I hope to be able to obtain UserControl2 as a variable within UserControl1's code and then assign it (UserControl2) to a position and have access to all of the components of "UserControl2".  The way I don't want to do it is to drag the UserControl2's icon from the bar onto the UI of UserControl1, I would like to do that programmatically.  I would be happy to provide more details if I was confusing.  Source code would be of great value.  Thanks...
0
Comment
Question by:halen
5 Comments
 
LVL 1

Expert Comment

by:hj2k3
ID: 8123920
to create any control dynamically, you need to have one control on the form, and set its index to 0. this creates a control array with one control in it. now you can type

Load myControl(myControl.UBound + 1)

this will create one more control, but by default it will not be visible, and in the same place as the one previous to it, so you will have to make it visible and move it in code afterwards.

i think if you have one control placed in a 1 man array, and then use Load, the new controls should be in the same container

hope this is what you're looking for
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 1000 total points
ID: 8124061
0
 
LVL 4

Expert Comment

by:JRCSystems
ID: 8124428
emoreau's link is correct.
0
 

Author Comment

by:halen
ID: 8129358
Sometimes, the hardest thing for me about programming is finding out the name of the method or function to use along with a good example.  That link was exactly what I needed.  I must also add that the algorithm worked for my Control within a Control, and I didn't need a Form like the first comment suggested.  Thanks to all for the help!
0
 
LVL 1

Expert Comment

by:hj2k3
ID: 8129642
emoreau's suggestion is good; it's a new one on me and i'll remember that in future. thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

569 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