BindingNavigator and DataGridView synchronization


G

Guest

1. The BindingNavigator and DataGridView generated by drag&Drop databinding
is misterious to me.
Eg when starting the code and loading an empty DB table, you get an empty
row. If you do not select it and press the DeleteItem button in
BindingNavigator, an exception is thrown: "InvalidOperationException",
"Current Item cannot be removed from the list because there us no current
item."

The same problem exists whenever a default row is inserted, selected or not
by the user and deleted.

Which code do I have to insert where to prevent this?

2. In validation, how do I check for cells that are DBNull if I cannot
compare to DBNull?

3. In the handler for DefaultValuesNeeded I select a cell which must be
filled by the user. This selection is sometimes displayed correctly,
sometimes not. Suppose it's a minor bug.

4. Obviously DataGridView rows do not have a RowState. This adds to the fact
that the DataTable.Count can be 2 off the actual number of displayed rows if
you use the AddItem button in BindingNavigator.

5. I want to achieve a behavious similar to MS-Access: whenever a row edit
ends (is validated) it is updated in the database without the user clicking
SaveItem.
I do this by callling TableAdapter.Update() in the RowValidated event handler.
The TableAdapter is set to ClearBeforeFill.
Is there a better way?

To sum all up:
What code is required to make the autogenerated BindingNavigator (AddItem,
DeleteItem) really work including cell defaults when editing in DataGridView?

thanks herbert
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top