Binding Navigator RRS feed

  • Question

  • I have a form that displays a record and uses a Binding Navigator, which I have never previously needed to use much.

    This presents no problem with me being able to use the binding navigator to display through the different records, provided I have set all of the controls DataBinding properties to the appropriate table.

    However, What I want to do is be able to use this same form for any of several lookup tables that I use.

    In my usual naivety, I believed this would be relatively easy and straight forward.  Alas, I was once again disappointed.

    Using the code below I was able to get the same display as above.  However, while the Binding Navigator behaved has expected, the display of the data did not change.

    I have been unable to figure out what else is needed to get the Binding Navigator and the data displayed in the controls together.

                        Dim strTable As String = "lkpDepartment"
                        Dim strDepartment As String = "chrDepartment"
                        Dim strCode As String = "chrCode"
                        Dim strDescription As String = "chrDescription"
                        With frmSettingsLookUp
                            .txtName.DataBindings.Add(New Binding("Text", frmSettingsLookUp._MasterBase_1_1DataSet, $"{strTable}.{strDepartment}"))
                            .txtCode.DataBindings.Add(New Binding("Text", frmSettingsLookUp._MasterBase_1_1DataSet, $"{strTable}.{strCode}"))
                            .txtDescription.DataBindings.Add(New Binding("Text", frmSettingsLookUp._MasterBase_1_1DataSet, $"{strTable}.{strDescription}"))
                            .frmSettingsLookUpBindingNavigator.BindingSource = frmSettingsLookUp.lkpDepartmentBindingSource
                        End With


    Tuesday, July 3, 2018 10:28 PM

All replies

  • Hello, 

    Using TableAdapter components do restrict flexibility of many operations when working with data. Also, having different tables usually means different fields so that would be an issue with defining TextBox controls as you have done. You are better off (depending how many lookup tables there are) hiding and showing panels on the form where each panel represents a lookup table.

    On a side note, there is no reason to use New Binding when data binding to controls.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, July 3, 2018 11:58 PM
  • Hi gwboolean

    I think you can add ToolStripButton and ToolStripTextBox after Binding Navigator control.

    Then write a method, the parameter is the table

     Public Sub data(ByVal name As String)
            Using conn = New SqlConnection(constr)
                sda = New SqlDataAdapter("Select * From " & name, conn)
                ds = New DataSet()
                sda.Fill(ds, "Table1")
                DataGridView1.AutoGenerateColumns = True
                DataGridView1.DataSource = ds
                DataGridView1.DataMember = "Table1"
                DataGridView1.MultiSelect = False
                bind.DataSource = ds.Tables("Table1")
                BindingNavigator1.BindingSource = bind
            End Using
        End Sub

    Call method:

     Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
        End Sub

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Wednesday, July 4, 2018 2:43 AM