OK, I was able to build the collection without help. Is there anyone that would care to tackle this problem? The code follows. The collections of buttons, labels, and textboxes are now exposed in the property window for the Usercontrol, code shown here. The problem is, when I add a control to the collection it is not apperant where it is placed. It shows up in code for the form in the Windows Generated Code section, but I can't locate it on the form or the Usercontrol.
The following code can be copied into a Usercontrol named WindowsControlLibrary2.
______________________________________________
Imports System.Windows.Forms
Imports System.Windows.Forms.Design
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing.Design
Imports System.Collections
Public Class UserControl1
Inherits System.Windows.Forms.UserControl
Private mButtons As ButtonCollection = New ButtonCollection
Private mLabels As LabelCollection = New LabelCollection
Private mTextBoxes As TextCollection = New TextCollection
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
mButtons = New ButtonCollection
mLabels = New LabelCollection
mTextBoxes = New TextCollection
End Sub
'UserControl1 overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Panel1 As System.Windows.Forms.Panel
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Panel1 = New System.Windows.Forms.Panel
Me.SuspendLayout()
'
'Panel1
'
Me.Panel1.Location = New System.Drawing.Point(24, 312)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(568, 320)
Me.Panel1.TabIndex = 0
'
'UserControl1
'
Me.Controls.Add(Me.Panel1)
Me.Name = "UserControl1"
Me.Size = New System.Drawing.Size(688, 416)
Me.ResumeLayout(False)
End Sub
#End Region
<Editor(GetType(CollectionEditor), GetType(UITypeEditor)), _
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)> _
Public Property sfButtons() As ButtonCollection
Set(ByVal Value As ButtonCollection)
mButtons = Value
End Set
Get
Return mButtons
End Get
End Property
<Editor(GetType(CollectionEditor), GetType(UITypeEditor)), _
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)> _
Public Property sfLabels() As LabelCollection
Set(ByVal Value As LabelCollection)
mLabels = Value
End Set
Get
Return mLabels
End Get
End Property
<Editor(GetType(CollectionEditor), GetType(UITypeEditor)), _
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)> _
Public Property sfTextBoxes() As TextCollection
Set(ByVal Value As TextCollection)
mTextBoxes = Value
End Set
Get
Return mTextBoxes
End Get
End Property
End Class
<Serializable()> _
Public Class ButtonCollection
Inherits CollectionBase
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal value As ButtonCollection)
MyBase.New()
Me.AddRange(value)
End Sub
Public Sub New(ByVal value() As Button)
MyBase.New()
Me.AddRange(value)
End Sub
Default Public Property Item(ByVal index As Integer) As System.Windows.Forms.Button
Get
Return CType(List(index), System.Windows.Forms.Button)
End Get
Set(ByVal Value As System.Windows.Forms.Button)
List(index) = Value
End Set
End Property
Public Function Add(ByVal value As Button) As Integer
Return List.Add(value)
End Function
Public Overloads Sub AddRange(ByVal value() As Button)
Dim i As Integer = 0
Do While (i < value.Length)
Me.Add(value(i))
i = (i + 1)
Loop
End Sub
Public Overloads Sub AddRange(ByVal value As ButtonCollection)
Dim i As Integer = 0
Do While (i < value.Count)
Me.Add(value(i))
i = (i + 1)
Loop
End Sub
Public Function Contains(ByVal value As System.Windows.Forms.Button) As Boolean
Return List.Contains(value)
End Function
Public Sub CopyTo(ByVal array() As Button, ByVal index As Integer)
List.CopyTo(array, index)
End Sub
Public Function IndexOf(ByVal value As Button) As Integer
Return List.IndexOf(value)
End Function
Public Sub Insert(ByVal index As Integer, ByVal value As Button)
List.Insert(index, value)
End Sub
Public Shadows Function GetEnumerator() As ButtonEnumerator
Return New ButtonEnumerator(Me)
End Function
Public Sub Remove(ByVal value As Button)
List.Remove(value)
End Sub
Public Class ButtonEnumerator
Inherits Object
Implements IEnumerator
Private baseEnumerator As IEnumerator
Private temp As IEnumerable
Public Sub New(ByVal mappings As ButtonCollection)
MyBase.New()
Me.temp = CType(mappings, IEnumerable)
Me.baseEnumerator = temp.GetEnumerator
End Sub
Public ReadOnly Property Current() As System.Windows.Forms.Button
Get
Return CType(baseEnumerator.Current, System.Windows.Forms.Button)
End Get
End Property
ReadOnly Property IEnumerator_Current() As Object Implements IEnumerator.Current
Get
Return baseEnumerator.Current
End Get
End Property
Public Function MoveNext() As Boolean
Return baseEnumerator.MoveNext
End Function
Function IEnumerator_MoveNext() As Boolean Implements IEnumerator.MoveNext
Return baseEnumerator.MoveNext
End Function
Public Sub Reset()
baseEnumerator.Reset()
End Sub
Sub IEnumerator_Reset() Implements IEnumerator.Reset
baseEnumerator.Reset()
End Sub
End Class
End Class
<Serializable()> _
Public Class LabelCollection
Inherits CollectionBase
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal value As LabelCollection)
MyBase.New()
Me.AddRange(value)
End Sub
Public Sub New(ByVal value() As Label)
MyBase.New()
Me.AddRange(value)
End Sub
Default Public Property Item(ByVal index As Integer) As System.Windows.Forms.Label
Get
Return CType(List(index), System.Windows.Forms.Label)
End Get
Set(ByVal Value As System.Windows.Forms.Label)
List(index) = Value
End Set
End Property
Public Function Add(ByVal value As Label) As Integer
Return List.Add(value)
End Function
Public Overloads Sub AddRange(ByVal value() As Label)
Dim i As Integer = 0
Do While (i < value.Length)
Me.Add(value(i))
i = (i + 1)
Loop
End Sub
Public Overloads Sub AddRange(ByVal value As LabelCollection)
Dim i As Integer = 0
Do While (i < value.Count)
Me.Add(value(i))
i = (i + 1)
Loop
End Sub
Public Function Contains(ByVal value As System.Windows.Forms.Label) As Boolean
Return List.Contains(value)
End Function
Public Sub CopyTo(ByVal array() As Label, ByVal index As Integer)
List.CopyTo(array, index)
End Sub
Public Function IndexOf(ByVal value As Label) As Integer
Return List.IndexOf(value)
End Function
Public Sub Insert(ByVal index As Integer, ByVal value As Label)
List.Insert(index, value)
End Sub
Public Shadows Function GetEnumerator() As LabelEnumerator
Return New LabelEnumerator(Me)
End Function
Public Sub Remove(ByVal value As Label)
List.Remove(value)
End Sub
Public Class LabelEnumerator
Inherits Object
Implements IEnumerator
Private baseEnumerator As IEnumerator
Private temp As IEnumerable
Public Sub New(ByVal mappings As LabelCollection)
MyBase.New()
Me.temp = CType(mappings, IEnumerable)
Me.baseEnumerator = temp.GetEnumerator
End Sub
Public ReadOnly Property Current() As System.Windows.Forms.Label
Get
Return CType(baseEnumerator.Current, System.Windows.Forms.Label)
End Get
End Property
ReadOnly Property IEnumerator_Current() As Object Implements IEnumerator.Current
Get
Return baseEnumerator.Current
End Get
End Property
Public Function MoveNext() As Boolean
Return baseEnumerator.MoveNext
End Function
Function IEnumerator_MoveNext() As Boolean Implements IEnumerator.MoveNext
Return baseEnumerator.MoveNext
End Function
Public Sub Reset()
baseEnumerator.Reset()
End Sub
Sub IEnumerator_Reset() Implements IEnumerator.Reset
baseEnumerator.Reset()
End Sub
End Class
End Class
<Serializable()> _
Public Class TextCollection
Inherits CollectionBase
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal value As TextCollection)
MyBase.New()
Me.AddRange(value)
End Sub
Public Sub New(ByVal value() As TextBox)
MyBase.New()
Me.AddRange(value)
End Sub
Default Public Property Item(ByVal index As Integer) As System.Windows.Forms.TextBox
Get
Return CType(List(index), System.Windows.Forms.TextBox)
End Get
Set(ByVal Value As System.Windows.Forms.TextBox)
List(index) = Value
End Set
End Property
Public Function Add(ByVal value As TextBox) As Integer
Return List.Add(value)
End Function
Public Overloads Sub AddRange(ByVal value() As TextBox)
Dim i As Integer = 0
Do While (i < value.Length)
Me.Add(value(i))
i = (i + 1)
Loop
End Sub
Public Overloads Sub AddRange(ByVal value As TextCollection)
Dim i As Integer = 0
Do While (i < value.Count)
Me.Add(value(i))
i = (i + 1)
Loop
End Sub
Public Function Contains(ByVal value As System.Windows.Forms.TextBox) As Boolean
Return List.Contains(value)
End Function
Public Sub CopyTo(ByVal array() As TextBox, ByVal index As Integer)
List.CopyTo(array, index)
End Sub
Public Function IndexOf(ByVal value As TextBox) As Integer
Return List.IndexOf(value)
End Function
Public Sub Insert(ByVal index As Integer, ByVal value As TextBox)
List.Insert(index, value)
End Sub
Public Shadows Function GetEnumerator() As TextEnumerator
Return New TextEnumerator(Me)
End Function
Public Sub Remove(ByVal value As TextBox)
List.Remove(value)
End Sub
Public Class TextEnumerator
Inherits Object
Implements IEnumerator
Private baseEnumerator As IEnumerator
Private temp As IEnumerable
Public Sub New(ByVal mappings As TextCollection)
MyBase.New()
Me.temp = CType(mappings, IEnumerable)
Me.baseEnumerator = temp.GetEnumerator
End Sub
Public ReadOnly Property Current() As System.Windows.Forms.TextBox
Get
Return CType(baseEnumerator.Current, System.Windows.Forms.TextBox)
End Get
End Property
ReadOnly Property IEnumerator_Current() As Object Implements IEnumerator.Current
Get
Return baseEnumerator.Current
End Get
End Property
Public Function MoveNext() As Boolean
Return baseEnumerator.MoveNext
End Function
Function IEnumerator_MoveNext() As Boolean Implements IEnumerator.MoveNext
Return baseEnumerator.MoveNext
End Function
Public Sub Reset()
baseEnumerator.Reset()
End Sub
Sub IEnumerator_Reset() Implements IEnumerator.Reset
baseEnumerator.Reset()
End Sub
End Class
End Class
______________________________________________
Form1 code:
______________________________________________
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents UserControl11 As WindowsControlLibrary2.UserControl1
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.UserControl11 = New WindowsControlLibrary2.UserControl1
Me.SuspendLayout()
'
'UserControl11
'
Me.UserControl11.Location = New System.Drawing.Point(40, 56)
Me.UserControl11.Name = "UserControl11"
Me.UserControl11.Size = New System.Drawing.Size(688, 416)
Me.UserControl11.TabIndex = 0
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(760, 541)
Me.Controls.Add(Me.UserControl11)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
End Class
______________________________________________
|