Reputation: 6778
I've tried the following:
Compile error (on last As)
Dim myList As New List(Of Object)
myList = dataGridView.DataSource As List<Object>
Throws Unable to cast object of type System.Windows.Forms.BindingSource:
myList = dataGridView.DataSource
DataSource is a System.ComponentModel.BindingList<T>
where T is a custom class.
Upvotes: 0
Views: 3157
Reputation: 6778
This is how I did it:
Dim MyList As New List(Of Object) ' Of MyClass?
For Each myClass As MyClass In dataGridView.DataSource
MyList.Add(myClass )
Next
Upvotes: 0
Reputation: 1792
You could do something like this
myList = dataGridView.Rows.OfType(Of Object).ToList()
Upvotes: 1