Referring to Dynamically loaded UserControl in VB.NET

Posted on 2009-04-22
Last Modified: 2012-05-06
if I have this code:

for x = 0 to totalPics
     Me.TabPage2.Controls.Add(New NamesControl.ProductImage)

How would I refer the the created control?
Question by:steverguy
    LVL 2

    Expert Comment


    give the control an id when you add it to the tabpage then do.

    dim control as NamesControl
    control = Me.TabPage2.findcontrol("controlID")
    LVL 2

    Accepted Solution

    sorry i forgot to suggest using the x for the id so

    for x = 0 to totalPics
         dim cont as new namescontrol.productimage = "id_" & x.tostring

    then you'd loop through when referring to it i guess or however you would need to.
    LVL 1

    Author Comment

    it didn't seem to like - but i was able to use

    Thanks for he help!

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 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

    16 Experts available now in Live!

    Get 1:1 Help Now