Reputation: 679
I'm trying to bind the BindingNavigator to a BindingSource. It works very good, but the problem is the yellow plus icon is disabled. How can I make it enabled?
I created manually with code the dataset, tableadapters and the bindingsource, but when I bind it on the bindingnavigator it shows the records but it doesn't enable "Delete" and "Add Item".
What im doing wrong?
Code from comment:
Dim connstr As String = "Data Source=" + Application.StartupPath + "\Prueba.sdf"
Dim conn As New SqlCeConnection(connstr)
Dim cmd As New SqlCeCommand("SELECT * FROM datos", conn)
Dim inscmd As New SqlCeCommand("INSERT INTO datos VALUES (@nombre,@apellido,@id)", conn)
dt = New SqlCeDataAdapter(cmd)
dt.Fill(DataSet1, "datos")
dt.InsertCommand = inscmd
BindingSource1.DataSource = DataSet1
DataGridView1.DataSource = BindingSource1
DataGridView1.DataMember = "datos"
DataGridView1.Columns("id").Visible = False
Upvotes: 3
Views: 6045
Reputation: 13
For fun I added a 2nd text box on the form, a 2nd column in the table, and populated the two fields for both records.
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
dt.TableName = "English"
dt.Columns.Add("Words")
dt.Columns.Add("Spanish")
dt.Rows.Add("Hello", "Hola")
dt.Rows.Add("Good-Bye", "Adios")
ds.Tables.Add(dt)
bs.DataSource = ds
bs.DataMember = "English"
TextBox1.DataBindings.Add("Text", bs, "Words")
TextBox2.DataBindings.Add("Text", bs, "Spanish")
BindingNavigator1.BindingSource = bs
End Sub
Upvotes: 0
Reputation: 81610
Since you provided no code, you made it really hard to try to solve your problem.
Here is an example that works. Take a new form, drop a TextBox
and BindingNavigator
controls on it.
Add this code:
Public Class Form1
Private bs As New BindingSource
Private ds As New DataSet
Private dt As New DataTable
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
dt.TableName = "English"
dt.Columns.Add("Words")
dt.Rows.Add("Hello")
dt.Rows.Add("Good-Bye")
ds.Tables.Add(dt)
bs.DataSource = ds
bs.DataMember = "English"
TextBox1.DataBindings.Add("Text", bs, "Words")
BindingNavigator1.BindingSource = bs
End Sub
End Class
The TextBox
should have "Hello" in it. The BindingNavigator
should have "1 of 2" on it, plus the Add and Delete buttons should be enabled and working.
If this doesn't help solve the problem, you will have to post some code to help us reproduce the problem.
Upvotes: 1