Refresh Binding Navigator Upon Row Delete

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

I'm having a problem with the binding navigator on a form in that it
won't reflect the results of a deleted record. The binding source is
a single table bound to a sql db as its data source. When I call the
code to delete a record (always a single record), the code executes
properly and the record is deleted from the data source. However, the
binding navigator doesn't reflect this deletion.

Say there are three records in the table and I am deleting record #1.
Immediately prior to the delete, the binding navigator shows that I am
on "1 of 3", which is of course correct. After the deletion, the
binding navigator shows that I am on record "2 of 3" rather than what
it should display, which is "1 of 2". If I click on MovePrevious, the
deleted record is still displayed even though it is no longer in the
datasource. (Note: There is a MoveNext command in the deletion code,
which is why it advances to record 2. If I take this out, it remains
on "1 of 3".)

If I close and reload the form, then the display is accurate - "1 of
2". Again, the record has been deleted, this is just about making the
binding navigator display this fact.

What am I missing? Thanks.
 
Alex,

Normally, when the BindingNavigator's Delete button is clicked the
BindingNavigator calls the BindingSource's RemoveCurrent method.

However, you can clear the BindingNavigator's DeleteItem property and handle
deletes in some custom way.

But if you do that then it is up to you to call the BindingSource's
RemoveCurrent method.

Kerry Moorman
 
Back
Top