?
Solved

Need to Programmatically add a UserControl onto my UserControl

Posted on 2003-03-12
5
Medium Priority
?
169 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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
Course of the Month8 days, 3 hours left to enroll

765 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