Hi
My Problem is this. I have a form that contains a custom control. This Custom control contains a custom collection that contains custom classes. When I do any changes in design time the changes are lost when I close the design window.
Can anybody help me with the problem?
The code for the Custom control:
The code for the custom collection
And finally the code for the collection item
My Problem is this. I have a form that contains a custom control. This Custom control contains a custom collection that contains custom classes. When I do any changes in design time the changes are lost when I close the design window.
Can anybody help me with the problem?
The code for the Custom control:
VB.NET:
Imports System.ComponentModel
Public Class ctlFilter
Public Event FilterChanged()
Private WithEvents m_FilterItems As clsFilterItems
<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
Public ReadOnly Property FilterItems() As clsFilterItems
Get
Return m_FilterItems
End Get
End Property
End Class
The code for the custom collection
VB.NET:
Imports System.ComponentModel
Public Class clsFilterItems
Inherits CollectionBase
Public Event Changed()
Public Sub Add(ByVal FilterItem As clsFilterItem)
List.Add(FilterItem)
RaiseEvent Changed()
End Sub
Public Sub Remove(ByVal index As Integer)
If index > Count - 1 Or index < 0 Then
System.Windows.Forms.MessageBox.Show("Index not valid!")
Else
List.RemoveAt(index)
End If
End Sub
Public ReadOnly Property Item(ByVal index As Integer) As clsFilterItem
Get
Return CType(List.Item(index), clsFilterItem)
End Get
End Property
End Class
And finally the code for the collection item
VB.NET:
Imports System.ComponentModel
Public Class clsFilterItem
Public Enum e_Type
DateTime
DropDown
Text
End Enum
Private _Name As String
Private _FilterColumn As String
Private _BS As New BindingSource()
Private _ValueMember As String
Private _DisplayMember As String
Private _Type As e_Type
<Category("General")> _
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Public Property FilterColumn() As String
Get
Return _FilterColumn
End Get
Set(ByVal value As String)
_FilterColumn = value
End Set
End Property
<TypeConverter("System.Windows.Forms.Design.DataMemberFieldConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), DefaultValue(""), Category("Data"), Editor("System.Windows.Forms.Design.DataMemberFieldEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", GetType(Drawing.Design.UITypeEditor))> _
Public Property ValueMember() As String
Get
Return _ValueMember
End Get
Set(ByVal value As String)
_ValueMember = value
End Set
End Property
<TypeConverter("System.Windows.Forms.Design.DataMemberFieldConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), DefaultValue(""), Category("Data"), Editor("System.Windows.Forms.Design.DataMemberFieldEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", GetType(Drawing.Design.UITypeEditor))> _
Public Property DisplayMember() As String
Get
Return _DisplayMember
End Get
Set(ByVal value As String)
_DisplayMember = value
End Set
End Property
<Category("Data"), AttributeProvider("System.ComponentModel.IListSource")> _
Public Property DataSource() As BindingSource
Get
Return _BS
End Get
Set(ByVal value As BindingSource)
_BS = value
End Set
End Property
End Class