In the example below you'll see that the first example I give is of an ArrayList containing Person objects. This binds to the DataGridView with no problems.
In the second example I'm using an ArrayList with Strings. If I were to try and bind StringArrayList to the DataGridView you'd get a column named Length with each value showing how long the string is. This is because String is a Reference Type rather than a Value Type. The DataGridView is looking for properties to bind to and since String is a Reference Type the only thing it can see is Length.
The easiest way to get around this is to create a wrapper class around the String with a Value property so the DataGridView can see that.
Code:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim PersonArrayList As New ArrayList
With PersonArrayList
.Add(New Person With {.FirstName = "Jim", .LastName = "Jones"})
.Add(New Person With {.FirstName = "Peggy", .LastName = "Sue"})
.Add(New Person With {.FirstName = "John", .LastName = "Smith"})
End With
DisplayDataGridView.DataSource = PersonArrayList
Dim StringArrayList As New ArrayList
With StringArrayList
.Add("Test 1")
.Add("Test 101")
.Add("Test 10101")
End With
Dim StringValueArray = Array.ConvertAll(StringArrayList.ToArray(), AddressOf GetStringValue)
StringDataGridView.DataSource = StringValueArray
End Sub
Private Function GetStringValue(s As String) As StringValue
Return New StringValue(s)
End Function
End Class
Public Class Person
Public Property FirstName As String
Public Property LastName As String
Public ReadOnly Property FullName As String
Get
Return String.Join(", ", LastName, FirstName)
End Get
End Property
End Class
Public Class StringValue
Public Property Value As String
Public Sub New(s As String)
_Value = s
End Sub
End Class
All of that being said if you have a version of .NET that supports List(Of T) you should use that rather than an ArrayList.