Load my Usercontrol into a form, dynamically, and multiple times

Posted on 2009-04-16
Last Modified: 2012-05-06
I created a usercontrol that displays an image an properties of a specific product.  
After loading product values into an array, I would like to use the array to create instances of the usercontrol on the form, with the array values assinging the usercontrol's properties.

I created a function (i found a referance online) with the following code:
Public Sub CreateControl()      
        Dim userControl As UserControl
        userControl = New NamesControl.ProductImage
        userControl.Location(CurX, CurY)
End Sub

I get the following error:
Property access must assign to the property or use its value.

This is my first userControl, so i could've done somethign wrong while creating it, but my hope was that i'd be able to load the userControl and set it's properties in the above function.

This may be vague - but, any ideas what i'm doing wrong?

Thanks for your help!
Question by:steverguy
    LVL 48

    Accepted Solution

    Is this the name or your user control ?
    If so you should do:

    Dim userControl As New NamesControl.ProductImage 

    Open in new window

    LVL 48

    Expert Comment

    Is this the name of your user control
    LVL 1

    Author Closing Comment

    Thank you!  Sorry I didn't respond sooner, i'm only here 2 times per week.
    LVL 48

    Expert Comment

    No problem!
    Glad I could help.

    Expert Comment

    I request some one to help me in UserControls :-

    Dynamically adding UserControl - Based on total number of rows returned from stored procedure.

    I row returned from storedprocedure is equal to 1 usercontrol.

    if 2 rows returned from storedprocedure will be equal to 2 usercontrols .. and so it will be increasing or decreasing based on number of rows returned from storedprocedure
    LVL 48

    Expert Comment

    chokka ,
    This question doesn't get the attention of the community and you should create a new thread and detail your problem.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    761 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

    8 Experts available now in Live!

    Get 1:1 Help Now