S
Stanley
I am working on a control and trying to use my custom collection with a
CollectionEditor. However, the collectio is never being held after I click
the OK button. The last set of properties is there but the member list is
blank. Below are some snippets from my control. Please help I am going crazy
trying to figure this out.
<ToolboxData("<{0}:myControl runat=server></{0}:myControl >"), _
PersistChildren(False), _
ParseChildren(False), _
DefaultProperty("Buttons")> _
Public Class myControl
Inherits System.Web.UI.Control
Private _buttons As ButtonCollection
<Editor(GetType(myCollectionEditor), GetType(UITypeEditor)),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.InnerDefaultProperty)> _
Public ReadOnly Property Buttons() As ButtonCollection
Get
Return _buttons
End Get
End Property
'code left out for shorter post
End Class
Public Class ButtonClass
Private _id As String
Public Property ButtonName() As String
Get
Return _id
End Get
Set(ByVal Value As String)
_id = Value
End Set
End Property
End Class
Public Class ButtonCollection
Inherits CollectionBase
Public ReadOnly Property Button(ByVal nIndex As Integer)
Get
Return CType(MyBase.List(nIndex), ButtonClass)
End Get
End Property
Public Sub Add(ByVal button As ButtonClass)
MyBase.List.Add(tab)
End Sub
Public Function IndexOf(ByVal button As ButtonClass)
Return MyBase.List.IndexOf(button)
End Function
End Class
Public Class myCollectionEditor
Inherits CollectionEditor
Public Sub New(ByVal type As Type)
MyBase.New(type)
End Sub
Protected Overrides Function CreateCollectionItemType() As Type
Return GetType(ButtonClass)
End Function
End Class
CollectionEditor. However, the collectio is never being held after I click
the OK button. The last set of properties is there but the member list is
blank. Below are some snippets from my control. Please help I am going crazy
trying to figure this out.
<ToolboxData("<{0}:myControl runat=server></{0}:myControl >"), _
PersistChildren(False), _
ParseChildren(False), _
DefaultProperty("Buttons")> _
Public Class myControl
Inherits System.Web.UI.Control
Private _buttons As ButtonCollection
<Editor(GetType(myCollectionEditor), GetType(UITypeEditor)),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.InnerDefaultProperty)> _
Public ReadOnly Property Buttons() As ButtonCollection
Get
Return _buttons
End Get
End Property
'code left out for shorter post
End Class
Public Class ButtonClass
Private _id As String
Public Property ButtonName() As String
Get
Return _id
End Get
Set(ByVal Value As String)
_id = Value
End Set
End Property
End Class
Public Class ButtonCollection
Inherits CollectionBase
Public ReadOnly Property Button(ByVal nIndex As Integer)
Get
Return CType(MyBase.List(nIndex), ButtonClass)
End Get
End Property
Public Sub Add(ByVal button As ButtonClass)
MyBase.List.Add(tab)
End Sub
Public Function IndexOf(ByVal button As ButtonClass)
Return MyBase.List.IndexOf(button)
End Function
End Class
Public Class myCollectionEditor
Inherits CollectionEditor
Public Sub New(ByVal type As Type)
MyBase.New(type)
End Sub
Protected Overrides Function CreateCollectionItemType() As Type
Return GetType(ButtonClass)
End Function
End Class