Question Accessing user control forms in panel

Clint79

Member
Joined
Apr 13, 2010
Messages
7
Programming Experience
Beginner
Hi,
I have a form with a panel to which I add an unknown amount of user control forms (Like the MS Access continuous form in a sub-form). Can someone tell me if it is possible to access the "sub forms".

E.g. If I have the following
User control form with text boxes etc. - IngCtlForm
Panel on my form - IngredientsPanel

If I do the following...

VB.NET:
Private sub BuildMyPanel (ByVal x as Integer)
 Dim i as integer
 For i = 1 to x
    Dim NewSubForm as new IngCtlForm
    IngredientsPanel.add(NewSubForm)
 Next
End Sub

Private sub TestBtn3_Click () Handles TestBtn3.click
  Call BuildMyPanel(3)
End Sub

How do I access the text boxes on the three user controls added to the panel?
Thank in advance for any help.
 
Panel's have a Control collection like form's do. You can always loop the Panel's Controls collection...
 
Hi JuggaloBrotha,

Thanks for the advice. Sorry but I'm a bit of a newbi, could you explain a little further. Some example code would really help.

Thanks

edit:
I figured it out thanks to your advice.

Me.IngredientsPanel.Controls(1).Controls("TextBox1").Text = "Hello"

Gives me access to the text in TextBox1 on the 2nd user control added.

Thanks again for the help.
 
Back
Top