R
Randy
Hi,
I'm have a form with a listbox and a few textboxes on it. Based on
the user's selection in the listbox, I want the bindingsource to
update the textboxes with the corresponding values. I have similar
code built for a combobox that works just fine, but when applying it
to a listbox bound to a dataview, I can't figure out how to return the
correct bindingsource index. No matter what item I select, my index
returns 0.
Private Sub lbUOM_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles lbUOM.SelectedIndexChanged
cn.Open()
Dim drv As DataRowView = CType(lbUOM.SelectedItem,
DataRowView)
tb.Text = drv.Item("USUOM").ToString
Dim index As Integer = bsUOM.Find("USUOM", tb.Text)
If index <> -1 Then 'it was found; move to that
position
bsUOM.Position = index
End If
cn.Close()
End If
End Sub
Can anybody see why this doesn't work? Is there a better way to
navigate the bindingsource based on a listbox selection? I don't see
this issue posted anywhere in this board.
Thanks,
Randy
I'm have a form with a listbox and a few textboxes on it. Based on
the user's selection in the listbox, I want the bindingsource to
update the textboxes with the corresponding values. I have similar
code built for a combobox that works just fine, but when applying it
to a listbox bound to a dataview, I can't figure out how to return the
correct bindingsource index. No matter what item I select, my index
returns 0.
Private Sub lbUOM_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles lbUOM.SelectedIndexChanged
cn.Open()
Dim drv As DataRowView = CType(lbUOM.SelectedItem,
DataRowView)
tb.Text = drv.Item("USUOM").ToString
Dim index As Integer = bsUOM.Find("USUOM", tb.Text)
If index <> -1 Then 'it was found; move to that
position
bsUOM.Position = index
End If
cn.Close()
End If
End Sub
Can anybody see why this doesn't work? Is there a better way to
navigate the bindingsource based on a listbox selection? I don't see
this issue posted anywhere in this board.
Thanks,
Randy