0

我正在为这个挠头...

使用 VB2010,我有一个绑定到数据集的 BindingNavigator。假设数据集中只有三个记录。

我按下 BindingNavigator 上的 ADD NEW 按钮,BN 现在显示一个附加记录(“record 3 of 4”)。但我无法让国阵导航到记录 4!数据集表示已添加另一条记录(通过 dataset.Tables(0).Rows.Count)。但我无法到那里输入新数据。

我知道如何将数据从数据集中返回到数据库。我见过的大多数例子都展示了如何做到这一点。但我还没有找到我的问题的答案。

我有一种感觉,这是我忽略的非常简单的事情。代码领域的任何人都有一个想法?

这是我用来设置 BN 的代码:

Sub SetDataBinding()
    Try
        bsCustomers.DataSource = ds.Tables(0)   'ds is my dataset
        txtCustomerName.DataBindings.Add(New Binding("text", bsCustomers, "CustomerName"))
        txtAddress1.DataBindings.Add(New Binding("text", bsCustomers, "Address1"))
        txtAddress2.DataBindings.Add(New Binding("text", bsCustomers, "Address2"))
        txtAddress3.DataBindings.Add(New Binding("text", bsCustomers, "Address3"))
        txtCity.DataBindings.Add(New Binding("text", bsCustomers, "City"))
        txtState.DataBindings.Add(New Binding("text", bsCustomers, "State"))
        txtZip.DataBindings.Add(New Binding("text", bsCustomers, "Zip"))
        txtHomePhone.DataBindings.Add(New Binding("text", bsCustomers, "HomePhone"))
        txtCellPhone.DataBindings.Add(New Binding("text", bsCustomers, "CellPhone"))
        txtNotes.DataBindings.Add(New Binding("text", bsCustomers, "Notes"))
        chkActive.DataBindings.Add(New Binding("checked", bsCustomers, "Active"))
        BindingNavigator1.BindingSource = bsCustomers

    Catch ex As Exception
        MsgBox(ex.Message)

    End Try
4

0 回答 0