Finding BindingSource.Position from Listbox Selection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Randy

    #1

    Finding BindingSource.Position from Listbox Selection

    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_SelectedI ndexChanged(ByV al sender As Object, ByVal e
    As System.EventArg s) Handles lbUOM.SelectedI ndexChanged

    cn.Open()

    Dim drv As DataRowView = CType(lbUOM.Sel ectedItem,
    DataRowView)
    tb.Text = drv.Item("USUOM ").ToString

    Dim index As Integer = bsUOM.Find("USU OM", 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

  • Randy

    #2
    Re: Finding BindingSource.P osition from Listbox Selection

    Anybody want to take a crack at this? Thanks.

    Comment

    • Randy

      #3
      Re: Finding BindingSource.P osition from Listbox Selection

      (sound of crickets chirping)...

      Comment

      • Randy

        #4
        Re: Finding BindingSource.P osition from Listbox Selection

        (sound of crickets chirping)...

        Comment

        • Nick E

          #5
          solution?

          Hi Randy,

          Did you find a solution to this? I have a combo box bound to a Access db Table - column 1. When the combo item is selected I want the same records column 2 entry to display in a text box. I'm struggling to get a decipherable explanation on how to use BindingSource for .net 2005.

          Any help would be gratfully received.

          Thanks,
          Nick

          EggHeadCafe - .NET Developer Portal of Choice

          Comment

          • Cor Ligthert[MVP]

            #6
            Re: solution?

            Nick,

            That goes automaticly as you databind the textbox to a table, and you do the
            same for the combobox using the datasource, then the currencymanager will
            set the current table-item in the textbox.

            You even need a New DataView for not doing that.

            I would use this newsgroup for information instead of the by you quoted one.
            This is common stuff here.

            Cor

            Comment

            Working...