I have a Visual Basic project that uses a form to save information to a XML database. The form controls are bound to a DataTableBindingSource and all is fine except the "AddNewItem" button on the BindingNavigator seems to be saving the form. This is not the behavior I expected since there is also a SaveItem button that works great for saving the data to the DataTable. And since I wish to automatically clear the form for a new record after saving, I wrote a routine that clears all the TextBoxes, CheckBoxes, DropDowns, etc… when the SaveItem is clicked. The SaveItem also writes the DataSet to the XML database so no data is lost, but then when I click the AddItem button, it saves the Cleared form over the existing record in the DataTable, so when I click the SaveItem the altered DateTable gets written to the XML Database. Is there any way to grab the control of the AddItem button and alter its behavior so that it doesn’t save the form, or am I not seeing a bigger problem if I did that? I Know I could write my own AddNewItem routine, but the button would be in the wrong place…
Asked
Active
Viewed 295 times
0

ndmeiri
- 4,979
- 12
- 37
- 45

Wishful Thinking
- 13
- 4
-
If you already have a save button to submit the form ,then why do u need an additional add button. Can you specify and post a screenshot of your ui,it will be more helpful to understand – Sumit raj May 24 '18 at 02:50
-
The Save button included with the Navigator does not create a new record, nor does it "reset" the form, clearing old data and getting ready for a new record. I know that I could do this programmatically but I was trying to separate the behavior of the Save and Add buttons. I hoped the save would save and clear the form (this currently works fine. I wrote code to clear the form after the save) but does not add a new record like the Add button does, so when I click the Add button, it saves the empty form over the existing record before it adds the new record to the table. How do I add SS of UI? – Wishful Thinking May 24 '18 at 15:49
-
By the way, thank you for your help... – Wishful Thinking May 24 '18 at 15:50