[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 723
  • Last Modified:

How to keep binding source current with datagrid row clicked...

In the attached code, bs is a bindingsource for a datagrid.  
bs.current always returns the first row in the grid regardless of which row in the grid has been clicked on.
How do I keep the bindingsource current with the visually sekected row on the datagrid?

Thanks in advance.
Public Function RemovePages(ByRef lex As LastException) As Boolean

        Dim fc As HPFFAFormClass = Nothing
        Dim fp As PageFileClass = Nothing
        Dim retval As Boolean = True

            fc = bs.Current
            For Each fp In frm.ListBoxPageFiles.SelectedItems
            frm.ListBoxPageFiles.DataSource = Nothing
            frm.ListBoxPageFiles.DataSource = fc.Pages
            frm.ListBoxPageFiles.DisplayMember = "PageName"
            frm.ListBoxPageFiles.ValueMember = "Pageno"

        Catch ex As Exception
            retval = False
            lex.Message = ex.Message
            If Not ex.InnerException Is Nothing Then
                lex.Detail = ex.InnerException.Message
            End If
            lex.Code = "System Exception"
            lex.Source = "FormManagerCtrl - RemovePages"

        End Try
        Return retval

    End Function

Open in new window

1 Solution
codefingerAuthor Commented:
Four hours later to work out  this simple solution with no help from Experts Exchange OR Google....
In selectionchanged event on datagrid --
bs.position = grid.currentrow.index

You guys should be paying me!   (grin)

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now