Binding Navigator Refresh Items

V

Vayse

The idea being that when a new asset is displayed, the program would
recalculate the values of some labels.
For example, when Previous or Next is clicked.
I set bLoaded=True when the form loads, as otherwise the code would once for
each asset in the database when the form was loading -
Me.AssetsTableAdapter.FillByAsset(Me.AssetsDataSet.Assets, stAssetCode)

Another problem is that when the Save is done, the RefreshItems runs twice
for each of these lines
Me.AssetsBindingSource.EndEdit()
Me.AssetsTableAdapter.Update(Me.AssetsDataSet.Assets)

And heres my code:

Private Sub AssetsBindingNavigator_RefreshItems(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
AssetsBindingNavigator.RefreshItems

If bLoaded Then
TidyNumbers()
bNewSchedule = False
DoCalcFields()
End If

End Sub

Should I be putting this code somewhere else? How often does
BindingNavigator_RefreshItems run?

Thanks
Vayse
 
B

Bart Mermuys

Hi,

Vayse said:
The idea being that when a new asset is displayed, the program would
recalculate the values of some labels.
For example, when Previous or Next is clicked.
I set bLoaded=True when the form loads, as otherwise the code would once
for each asset in the database when the form was loading -
Me.AssetsTableAdapter.FillByAsset(Me.AssetsDataSet.Assets, stAssetCode)

Another problem is that when the Save is done, the RefreshItems runs twice
for each of these lines
Me.AssetsBindingSource.EndEdit()
Me.AssetsTableAdapter.Update(Me.AssetsDataSet.Assets)

And heres my code:

Private Sub AssetsBindingNavigator_RefreshItems(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
AssetsBindingNavigator.RefreshItems

If bLoaded Then
TidyNumbers()
bNewSchedule = False
DoCalcFields()
End If

End Sub

Should I be putting this code somewhere else? How often does
BindingNavigator_RefreshItems run?

Can't you use AssetsBindingSource.PositionChanged event instead or does this
cause problems too ?

HTH,
Greetings
 
V

Vayse

Bart Mermuys said:
Can't you use AssetsBindingSource.PositionChanged event instead or does
this cause problems too ?
That makes it work much better, thank you.
 

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