.NET Framework - Databind DataGridView to List(of String)

Asked By herber on 05-May-08 04:28 PM
I use the following code to programmatically bind a DataGridView and a
BindingNavigator to various List(of myClass). This works fine with each
'myClass' offering public properties.

Dim mAllUsers As List(Of myClass)
mAllUsers = GetAllUsers()  'returns List(Of myClass)
Dim AllUsersBindingSource As New BindingSource(Me.components)
ControlStationInfoBindingNavigator.BindingSource = AllUsersBindingSource
ControlStationInfoDataGridView.AutoGenerateColumns = True
ControlStationInfoDataGridView.DataSource = AllUsersBindingSource
AllUsersBindingSource.DataSource = mAllUsers

If I change the code to
Dim mAllUsers As List(Of String)
mAllUsers = GetAllUsers()  'returns List(Of String)
then the DataGridView only displays one column containing the length of each
string.

I want only to display the strings in one column.

thank you very much, herbert




RobinS replied on 10-May-08 02:15 AM
You could try using a BindingList(of whatever) instead of a List. It has all
the inherent properties needed to bind a list to a binding list and thus to
a control.

RobinS.
GoldMail.com