Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > BindingNavigator and events?
 

BindingNavigator and events?

I want to check whether current record is saved or not before it navigate to another record, if it's not saved it will stop user from navigating to other records, I'm thinking to insert some logic to check it before calling move first, preious, next and last, and add new.

But I cannot find any events for those actions. Can anyone suggest me some ideas where I can implement my logic?

Thank you very much!!!
Barry Kwok  Wednesday, October 19, 2005 4:39 PM
You can double-click on the save-item and an event is created that you can call from e.g. the Row-leave event or from the cellvalidating or cellendedit event.
Also you can set the [table]BindingNavigatorSaveItem.Enabled to true or false to see whether saving is needed or not.

Hope this helps you going on?
Arjan Timmerman  Thursday, October 27, 2005 9:46 AM
Having the same problem.
How to cancel navigation to next row?
I need to be able to do that because of validation issue.
Jan Pukovec  Friday, November 18, 2005 1:57 AM

BindingNavigator and the BindingSource that it wraps do not offer validation and/or navigation cancellation mechanisms.

The closer validation happens to where data is being edited the more information your app has about what caused the data to become invalid.

In the case of simple binding (for instance, if your form contains text boxes bound to a data source ) then you can use the Control::Validating event to validate and possibly cancel navigation.

If your app contains a data grid view bound to a data table then you can use DataGridView::CellValidating event or DataGridView::RowValidatingEvent.

Hope this helps,
Daniel.

Daniel Herling - Student  Friday, November 18, 2005 11:35 PM

It's possible to have a form where you can't validate just a single control. A simple example;

Date Event Reported to Agency x:

Reason not reported:

One of them, and only one needs a value. You can't validate them during control validation, because if the user tabs into one, and they're both blank (because it's a new event), he can't tab out until he pust something in, whether correct or not.

Being able to cancel navigation would make this sort of case a lot easier.

mpswaim  Friday, September 07, 2007 3:30 PM

if you are using buttons to move first, next, or previous then on the click event of the button check the rowstate of the current row ; newly added row will have a rowstate of Detached, if you call the endEdit method of your binding source then the rowstate will be Added

if you modify the record by changing the value in a data-bound text box then the rowState will be Modified

so in the click event of your button:

if((DataRowView)this.Bs.Current).Row.RowState == DataRowState.Added ||

(DataRowView)this.Bs.Current).Row.RowState == DataRowState.Detached ||

(DataRowView)this.Bs.Current).Row.RowState == DataRowState.Modified)

{

//prompt the user to save or cancel the changes made

//if canceled then bs.MoveNext

}

//note Bs is your binding source

alihijazi  Sunday, September 09, 2007 7:26 PM

You can use google to search for other answers

Custom Search

More Threads

• KeyDown Search in DataGridView
• Hierarchical View For A Media Solution
• Button in DataGrid Column
• DataGridView CustomComboColumn BackColor turning black when DataBound
• DataGridView, checkbox and table.select()
• Resharing DataGridView Rows after unsharing them
• Master/Detail Datagridview addnew row to detiail grid show nothing
• showing 2 tables in a DataGridView using DataRelation
• Search for record in binding navigator
• there is a bug in the visual studio developer