G
Guest
A listbox, named 'lbxRooms', does not display changes when the datasource
bound to it changes. The revelant code:
Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnEdit.Click
DirectCast(lbxRooms.SelectedItem, DataRowView).Item("Name") =
Me.tbxName.Text
DirectCast(lbxRooms.SelectedItem, DataRowView).Item("Size") =
Me.numSize.Value
Dim bm As BindingContext = New BindingContext
Dim cm As CurrencyManager
cm = DirectCast(bm.Item(lbxRooms.DataSource), CurrencyManager)
cm.Refresh()
End Sub
The dataset does accept the changes, which I can confirm using another set
of controls that are grabbing data from the listbox's datasource:
Private Sub lbxRooms_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
lbxRooms.SelectedIndexChanged
tbxName.Text = DirectCast(lbxRooms.SelectedItem,
DataRowView).Item("Name").ToString
Me.numSize.Value = CInt(DirectCast(lbxRooms.SelectedItem,
DataRowView).Item("Size"))
End Sub
Please advise on how to get the listbox itself to display changes to its
datasource. Thank you.
--Noel
bound to it changes. The revelant code:
Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnEdit.Click
DirectCast(lbxRooms.SelectedItem, DataRowView).Item("Name") =
Me.tbxName.Text
DirectCast(lbxRooms.SelectedItem, DataRowView).Item("Size") =
Me.numSize.Value
Dim bm As BindingContext = New BindingContext
Dim cm As CurrencyManager
cm = DirectCast(bm.Item(lbxRooms.DataSource), CurrencyManager)
cm.Refresh()
End Sub
The dataset does accept the changes, which I can confirm using another set
of controls that are grabbing data from the listbox's datasource:
Private Sub lbxRooms_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
lbxRooms.SelectedIndexChanged
tbxName.Text = DirectCast(lbxRooms.SelectedItem,
DataRowView).Item("Name").ToString
Me.numSize.Value = CInt(DirectCast(lbxRooms.SelectedItem,
DataRowView).Item("Size"))
End Sub
Please advise on how to get the listbox itself to display changes to its
datasource. Thank you.
--Noel