I have created a WinForm that takes data from another application and saves it in a database. I use a BindingNavigator (I dragged the dataset table onto my form and got a navigator, bindingsource and more) to display and navigate through the records.
When records are added to the dataset/table the BindingNavigator doesn't update itself with the new info right away. It is like nothing was added.
I have to click on the BindingNavigator's next
item, previous
item or things like that so it will refresh itself and show the correct number of items.
Can someone tell me how I programmatically tell the BindingNavigator to show the updated values?
I have tried a lot of things but nothing has worked.
EDIT
I figured out what was going wrong. I was running on a different thread than the form. Code that worked for me:
this.tableAdapterManager.PieceTableAdapter.Insert(ints[4], ints[2], ints[6], ints[8], ints[10], ints[12], ints[14]);
this.tableAdapterManager.UpdateAll(this.slicerTestDBDataSet);
this.pieceBindingNavigator.Invoke(new Action(() => this.pieceTableAdapter.Fill(this.slicerTestDBDataSet.Piece)));
Earlier I didn't use Invoke to invoke the main thread so it didn't work properly.
First thing to do is check the update and insert statements are in the command text of the tableadapter.
Click on the tableadapter in the design view if the dataset and see the properties. In the properties you will see the update and insert sections with a + on the left. Expand this to see the command text.
If it is empty, then go back to the right click of the table adapter and select configure. Then look at the query designer and make sure everything in the table you want to update is checked. Then finish the wizard and go back and make sure the wizard created the insert and update statements.
I have found that sometimes one textbox will accept an update and others won't. I fixed this by deleting the textbox and adding a new textbox that I would rebind.