Referring to Dynamically loaded UserControl in VB.NET

if I have this code:

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

How would I refer the the created control?
LVL 1
steverguyAsked:
Who is Participating?
 
neo00000110Commented:
sorry i forgot to suggest using the x for the id so

for x = 0 to totalPics
     dim cont as new namescontrol.productimage
     cont.id = "id_" & x.tostring
     Me.TabPage2.Controls.Add(cont)
next

then you'd loop through when referring to it i guess or however you would need to.
0
 
neo00000110Commented:
hi,

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

dim control as NamesControl
control = Me.TabPage2.findcontrol("controlID")
0
 
steverguyAuthor Commented:
it didn't seem to like cont.id - but i was able to use cont.name.

Thanks for he help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.