I have created a Custom Type
Expand|Select|Wrap|Line Numbers
- Public Class Field
- Private Item As Integer
- Private Name As String = "FieldName"
- Public Property FieldName() As String
- Get
- Return Name
- End Get
- Set(ByVal value As String)
- Name = value
- End Set
- End Property
- End Class
Expand|Select|Wrap|Line Numbers
- Public Class Fields
- Inherits CollectionBase
- Default Public Property Item(ByVal Index As Integer) As Field
- Get
- Return CType(List.Item(Index), Field)
- End Get
- Set(ByVal value As Field)
- List.Item(Index) = value
- End Set
- End Property
- Public Sub Add(ByVal Item As Field)
- If List.Count = 0 Then
- List.Add(Item)
- Else
- For i = 0 To List.Count - 1
- Dim myField As New Field
- myField = List(i)
- If myField.FieldName = Item.FieldName Then
- Item.FieldName += "1"
- End If
- Next
- List.Add(Item)
- End If
- End Sub
- End Class
Expand|Select|Wrap|Line Numbers
- Public TableFields As New Fields
- Public Property Evarus_Fields() As Fields
- Get
- Return TableFields
- End Get
- Set(ByVal value As Fields)
- TableFields = value
- End Set
- End Property
In the designer I am able to access my class and save the items in the collection, but then entries in the designer are incorrect. The created entry actually causes a syntax error on the command ‘New’
Expand|Select|Wrap|Line Numbers
- Field1.FieldName = "ColumnA"
- New ProjectName.ControlName.Fields.Add(Field1)
Expand|Select|Wrap|Line Numbers
- Field1.FieldName = "ColumnA"
- ControlInstanceName.TableFields.Add(Field1)