Can I have an array of controls repeated somehow? (VB.net 2003)

Apexprim8

Member
Joined
Oct 6, 2005
Messages
18
Location
Cheshire, United Kingdom
Programming Experience
Beginner
Not sure how to word this but here goes:

I have options that I want a user to be able to select from my CheckListBox.

They then click a button and a page containing a list of items from the checklist box appears like this:



Item Name | Checkbox 1 | Checkbox 2 | Checkbox 3



This is repeated down the page an arbitrary number of times.

How can I create an object that I can paste on a form to do this?

Thanks for any help.

Apex
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,602
Location
Sydney, Australia
Programming Experience
10+
You could create a UserControl that has all the possible controls on it at design time. You would then define the constructor(s) such that you could tell it which controls to show and which to hide, e.g. create a UserControl with a Label, a TextBox and a Button:
VB.NET:
Friend Class MyUserControl

    Public Sub New(ByVal showLabel As Boolean, ByVal showTextBox As Boolean, ByVal showButton As Boolean)
        Me.Label1.Visible = showLabel
        Me.TextBox1.Visible = showTextBox
        Me.Button1.Visible = showButton
     End Sub

End Class
Obviously your implementation would need to be a bit more complex but you get the idea. If you need a number of these controls you could either call the constructor repeatedly or you could define a Clone method.
 
Top Bottom