[VB.NET] Property inherits CollectionBase

Fruity

Member
Joined
Sep 28, 2004
Messages
6
Programming Experience
1-3
Hi,

I develop with VS.NET in VB.NET
I create one class which inherits from CollectionBase

------------------------------------
Public Class StringValeur

Private _sValeur As String

Public Property Valeur() As String
Get
Return _sValeur
End Get
Set(ByVal Value As String)
_sValeur = Value
End Set
End Property

End Class

Public Class CollectionValeur
Inherits CollectionBase

'''<summary>Propriété d'accès à l'<B>item de la collection CollectionValeur</B></summary>
Default Public Property Item(ByVal index As Integer) As StringValeur
Get
Return CType(InnerList(index), StringValeur)
End Get
Set(ByVal Value As StringValeur)
InnerList(index) = Value
End Set
End Property
'''<summary>Ajoute un item à la collection.</summary>
Public Function Add(ByVal value As StringValeur) As Int32
Return InnerList.Add(value)
End Function

'''<summary>Détermine la valeur d'index représentant la position de l'item spécifié dans la collection.</summary>
Public Function IndexOf(ByVal value As StringValeur) As Int32
Return InnerList.IndexOf(value)
End Function

'''<summary>Insert un item dans la collection à la position indiquée.</summary>
Public Sub Insert(ByVal index As Int32, ByVal value As StringValeur)
InnerList.Insert(index, value)
End Sub

'''<summary>Supprime un item de la collection.</summary>
Public Sub Remove(ByVal value As StringValeur)
InnerList.Remove(value)
End Sub

'''<summary>Détermine si la collection contient l'élément spécifié.</summary>
Public Function Contains(ByVal value As StringValeur) As Boolean
' If value is not find, this will return false.
Return InnerList.Contains(value)
End Function

End Class
--------------------------------------

I have in my control web, one property of type this class

Private _arListValeursPossibles As CollectionValeur

'''<summary>Propriété d'accès à la liste des valeurs possibles.</summary>
<Description(""), PersistenceMode(PersistenceMode.InnerProperty)> _
Public Property ListValeursPossibles() As CollectionValeur
Get
Return _arListValeursPossibles
End Get
Set(ByVal Value As CollectionValeur)
_arListValeursPossibles = Value
End Set
End Property

My problem is :
I want to modify this property in design mode with property popup
But the ListValeursPossibles property must be instancie
How and where ?

If I instancie it in handler load of control or page, I lost value of design mode
If I not instancie it, I have one error

I want to be able to modify this property in mode design to not write code each time I put control on web page

Thanks in advance




 
Top Bottom