BindingNavigator & Form Validation

mafrosis

Well-known member
Joined
Jun 5, 2006
Messages
88
Location
UK
Programming Experience
5-10
Hey all, I recently used a BindingNavigator object to give some of our novice users a familiar Access-style interface for moving through a large dataset.

The problem I found was validating a form when the person changes record - which event did any of you guys catch? Its a pain because MoveNext, MovePrev, MoveFirst & MoveLast all need handling - plus typing into the current record text box..

I opted to handle BindingSource.PositionChanged, but even this was a pain due to the fact that the BindingSource position has already changed when you enter the event handler!! So if validation fails you must have saved the previous record to move back to manually..

I hope that makes sense.. There must be an easier way to do this!!

Anyone done it?
Cheers
mafro
 
You shouldn't be validating your bound controls on events of the BindingSource or the BindingNavigator. You should be using events of the bound controls. Assuming that you're using a DataGridView then it has CellValidating, CellValidated, RowValidating and RowValidated events. If you're using other controls then they'll also have Validating and Validated events.
 
Fair enough, i dont use the Validating/Validated events so ill look into them.

The most part of this is that I need to ensure that for every record people have populated all fields on a form (2 textboxes & selecting from 2 listboxes). This can't really be done on a per-control basis, as it needs all controls to be checked - it has to be at point of changing record..

Any ideas?
Thanks
 
Back
Top