I'm trying to place BindingList data into a default DataGridView, but without success. If I run the Form, it shows a DataGridView with empty rows. So the number of rows is correct, but the data itself is missing.
Imports System.ComponentModel
Public Class Form1
Public Sub New()
InitializeComponent()
'Declare BindingList
Dim bList As BindingList(Of User)
'Init BindingList Constructor
bList = New BindingList(Of User)()
'List -> BindingList
'Dim bindingList = New BindingList(Of Person)(list)
'BindingList Settings
bList.AllowNew = True
bList.AllowRemove = True
bList.AllowEdit = True
bList.RaiseListChangedEvents = True
'Add Object
bList.Add(New User() With {.id = 1, .firstName = "Jeff", .lastName = "Tree"})
bList.Add(New User() With {.id = 2, .firstName = "Loes", .lastName = "Stone"})
'BindingList -> DataGridView
Dim source = New BindingSource(bList, Nothing)
DataGridView1.DataSource = bList
End Sub
End Class
Public Class User
Sub New()
End Sub
Public id As Integer
Public firstName As String
Public lastName As String
End Class
Result:
