There is code for save button, but I can't see any code behind the Add button though the button works ?
So what would it be as I want to create my own not from scratch ?
Thanks.
There is code for save button, but I can't see any code behind the Add button though the button works ?
So what would it be as I want to create my own not from scratch ?
Thanks.
I'm not offering Bounty (don't know exactly what it is but let's do it :))
The way the add button wires up, is to the underlying type or BindingSource. Based on the behavior I saw yesterday, if the underlying list was bound to a type that had an empty constructor it was enabled, if not, the button was disabled. So it should be
this.bindingNavigator1.BindingSource.AddNew();
this.bindingNavigator1.BindingSource.MoveLast();
if you have something where you don't want the default constructor use something like this:
this.bindingNavigator1.BindingSource.Add(new T(1));
this.bindingNavigator1.BindingSource.MoveLast();
The save code would be as such:
If you are using a strongly typed dataset the code would be like
DataSet.AcceptChanges();
or if using tableAdapters
var myTableAdapter=new DataSet1TableAdapters.assetTableAdapter();
myTableAdapter.Update(DataSet);
You may not be getting many views on a holiday/weekend.
If you are using strongly typed data source ( linke BindingSource ) to bind to BindingNavigator the Add button should work out of the box along with the other buttons like Move First,Next,Last,Previous, PoistionItem ( the textbox showing current record ).
To add your own handler for the Add button on bindingNavigator ( bindingNavigatorAddNewItem ), please follow the steps given below: 1. right click on add button and select properties from context menu. 2. In the properties window goto events tab. ( The one with symbol of lightning ) 3. Double click on Click. It will create an event handler in your code file.
If the Add button is disabled you can enable it by selecting enable from context menu on Add button.