Приведенный ниже код показывает, как это работает:
Protected WithEvents myWordClueList As WordClueList
Protected gridBindingSource As BindingSource
Public Sub New()
' This call is required by the designer.
InitializeComponent()
myWordClueList = New WordClueList()
myWordClueList.Add(New WordCluePair With {.Word = "Eden", .Clue = "First garden"})
myWordClueList.Add(New WordCluePair With {.Word = "Fears", .Clue = "Aggregate of negative emotions"})
' Instantiate a binding source for the GridView
gridBindingSource = New BindingSource With {.DataSource = myWordClueList}
WordClueGrid.DataSource = gridBindingSource
End Sub
Хитрость заключается в использовании объекта Binding Source.
Чтобы обновить GridView при внесении изменений в DataSource, вызовите метод ResetBindings вашего объекта BindingSource.
myWordClueList.OrderBy(Function(pairRow As WordCluePair) pairRow)
gridBindingSource.ResetBindings(False)