tags:

views:

646

answers:

4

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.

A: 

Only 4 persons have viewed the question ?

programmernovice
USE COMMENTS !!!
P.K
A: 

I'm not offering Bounty (don't know exactly what it is but let's do it :))

programmernovice
use comments !!
P.K
+2  A: 

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.

Maslow
sorry meant to say double clicking the save button, if you are looking for where to put your code. the rest applies to if you are trying to make a save button. Which depends on what technologies you are using to connect to the database.
Maslow
I'm not asking about the save button but the add button :Sure I did see the code behind the save button already but I can't see any behind the add button :)
programmernovice
Here's some additional information that may be helpful: http://briannoyes.net/CommentView,guid,64275c83-d7af-4a19-b4f7-593146ab415f.aspx
Maslow
OK seems what I need thanks :)
programmernovice
+1  A: 

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.

Mahin