I have the following problem. I created a custom control derived from DataGrid and I created a custom codeDomSerializer to take care of the design time. Here is a part of the generator that creates a new BinderCollection and adds Binder items to it. Just as a note, the BinderCollection derives from CollectionBase and has a Default Readonly property called "Item" that returns a "Binder" type:

Private Shared Function GenerateBinderStatement(ByVal i As Integer, ByVal target As CodePropertyReferenceExpression, ByVal b As Binder) As CodeStatementCollection
Dim sresult As CodeStatementCollection = New CodeStatementCollection()

Dim b1p As CodePropertyReferenceExpression
Dim item As CodePropertyReferenceExpression
item = New CodePropertyReferenceExpression(target, "Item")
Dim b1 As CodeIndexerExpression
b1 = New CodeIndexerExpression(item, New CodePrimitiveExpression(i))
.............

Using this routine, the following code gets created:

Me.MyGrid1.Binders = New BinderCollection()
Me.MyGrid1.Binders.Add(New Binder())
Me.MyGrid1.Binders.Add(New Binder())
Me.MyGrid1.Binders.Item(0).ConnType = ConnectionType.Unknown
Me.MyGrid1.Binders.Item(1).ConnType = ConnectionType.Unknown

However, at deserialization time here is what the deserializer gets (I created a dump to disk routine in the deserialization function):

#ExternalSource("E:\MyWork\Visual Studio Projects\WindowsApplication2\Form1.vb",61)
Me.PlusGrid1.Binders = New BinderCollection
#End ExternalSource

#ExternalSource("E:\MyWork\Visual Studio Projects\WindowsApplication2\Form1.vb",62)
Me.PlusGrid1.Binders.Add(New Binder)
#End ExternalSource

#ExternalSource("E:\MyWork\Visual Studio Projects\WindowsApplication2\Form1.vb",63)
Me.PlusGrid1.Binders.Add(New Binder)
#End ExternalSource

#ExternalSource("E:\MyWork\Visual Studio Projects\WindowsApplication2\Form1.vb",65)
Me.PlusGrid1.Binders.Item.ConnType = GetType(ConnectionType).Unknown
#End ExternalSource

#ExternalSource("E:\MyWork\Visual Studio Projects\WindowsApplication2\Form1.vb",67)
Me.PlusGrid1.Binders.Item.ConnType = GetType(ConnectionType).Unknown
#End ExternalSource

Notice the last two lines:

Me.PlusGrid1.Binders.Item.ConnType = GetType(ConnectionType).Unknown
Me.PlusGrid1.Binders.Item.ConnType = GetType(ConnectionType).Unknown

What happens with my array indexer?? The lines should be:

Me.PlusGrid1.Binders.Item(0).ConnType = GetType(ConnectionType).Unknown
Me.PlusGrid1.Binders.Item(1).ConnType = GetType(ConnectionType).Unknown

What am I missing here?

Thank you very much!!!


Best Regards,

Iulian Florin Ionescu