BindingSource1.AddNew()

G

Guest

Help,

I have created Windows app with VS2005.
I then drop the datanavigator control and bindingsource control to the form.

I bind a dataset tablet to the binding source and set the navigator to the
bindingsource control , all wonderfull.

The Problem

I click to add a new record , it doesnt go to the end ? it goes to record 1
and seems to lose records 1 data.

I have tried adding my own button on there with the code

BindingSource1.AddNew()

, but this does the same. How do I got to the newly created record.


Thanks


Neil
 
G

Guest

Well I have managed to solve my problem so thought Id post incase anyone else
has this stress.

The problem was the add new button of the navigator was not going to a new
record at the end. Instead it would increment the record counter and stay at
the current position.

The code that causes the problem ;

'Code to get conn etc then

SQLAdapter.Fill(myDataSet,"Products")

' Associate the DataSet with the BindingSource.
Me.ProductsBindingSource.DataMember = "Products"
Me.ProductsBindingSource.DataSource = myDataset.Tables("Products")

' Associate the BindingNavigators with the BindingSource
Me.BindingNavigator1.BindingSource = Me.ProductsBindingSource

txtProductName.DataBindings.Add("Text",Me.ProductsBindingSource,"ProductName")

chkProductBlocked.DataBindings.Add("Checked",Me.ProductsBindingSource,"ProductBlocked")

There is no exception raised and you end up pulling out your hair. The
problem was with the binding on the checkbox. Changing that line to the
following ;


chkProductBlocked.DataBindings.Add("CheckState",Me.ProductsBindingSource,"ProductBlocked",True)

Solved my problem and made the datanavigator behave how you would expect.

I hope it all makes sense and helps someone who may come across the same
problem.

Thanks


Neil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top