Why is it that this doesn't work? (I will follow up with another email with an example that does work....only difference is the type of object that gets added to the arraylist).
Imports System.ComponentModel Public Class C Inherits ArrayList Implements IBindingList Public Sub New() Dim v As New CC() v.XX = "First Element" Me.Add(v) v = New CC() v.XX = "Second Element" Me.Add(v) End Sub Public Function AddNew() As Object Implements IBindingList.AddNew Return Nothing End Function Public ReadOnly Property AllowEdit() As Boolean Implements IBindingList.AllowEdit Get Return True End Get End Property Public ReadOnly Property AllowNew() As Boolean Implements IBindingList.AllowNew Get Return True End Get End Property Public ReadOnly Property AllowRemove() As Boolean Implements IBindingList.AllowRemove Get Return True End Get End Property Public Event ListChanged As ListChangedEventHandler Implements IBindingList.ListChanged Friend Sub OnListChanged(ByVal args As ListChangedEventArgs) RaiseEvent ListChanged(Me, args) End Sub Sub AddIndex(ByVal prop As PropertyDescriptor) Implements IBindingList.AddIndex Throw New NotSupportedException() End Sub Sub ApplySort(ByVal prop As PropertyDescriptor, ByVal direction As ListSortDirection) Implements IBindingList.ApplySort Throw New NotSupportedException() End Sub Function Find(ByVal prop As PropertyDescriptor, ByVal key As Object) As Integer Implements IBindingList.Find Throw New NotSupportedException() End Function Sub RemoveIndex(ByVal prop As PropertyDescriptor) Implements IBindingList.RemoveIndex Throw New NotSupportedException() End Sub Sub RemoveSort() Implements IBindingList.RemoveSort Throw New NotSupportedException() End Sub ReadOnly Property IsSorted() As Boolean Implements IBindingList.IsSorted Get Throw New NotSupportedException() End Get End Property ReadOnly Property SortDirection() As ListSortDirection Implements IBindingList.SortDirection Get Throw New NotSupportedException() End Get End Property ReadOnly Property SortProperty() As PropertyDescriptor Implements IBindingList.SortProperty Get Throw New NotSupportedException() End Get End Property ReadOnly Property SupportsChangeNotification() As Boolean Implements IBindingList.SupportsChangeNotification Get Return True End Get End Property ReadOnly Property SupportsSearching() As Boolean Implements IBindingList.SupportsSearching Get Return False End Get End Property ReadOnly Property SupportsSorting() As Boolean Implements IBindingList.SupportsSorting Get Return False End Get End Property Public Function GetXML() Me.TrimToSize() Dim serializer As New System.Xml.Serialization.XmlSerializer(GetType(C)) Dim writer As New System.IO.StringWriter() Dim Obj As C Obj = Me serializer.Serialize(writer, Obj) Dim s As String s = writer.ToString Console.Write(s) writer.Close() Return s End Function End Class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(24, 32) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 109) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1}) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim X As New C() MsgBox(X.GetXML) End Sub End Class Public Class CC Dim X As String Public Property XX() As String Get Return X End Get Set(ByVal Value As String) X = Value End Set End Property End Class You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.