Newbie question about form events

G

Guest

I'm converting from a VBA environment. What event fires when the form is
loaded with the current record, similar to the form..current event in VBA?
I've got a vs project with an mdb that has the path for an image, along with
some other fields. When I open the project, the first record displays just
fine. But when I click on the "move next" button on the binding navigator,
the next record displays but the image doesn't change. When I debug the
code, the path is from the previous record. So it's always one record
behind. Here's a snippet of my code to explain what I mean. This code is in
the BindingNavigatorMoveNextItem_Click event:

If Me.txtImageFileName IsNot DBNull.Value Then
Me.PhotoOrImage.Image = Image.FromFile(Me.txtImageFileName.Text)
End If

txtImageFileName is the text box containing the path name and gets its value
from the mdb.

I assume I need to put this code in an event similar to form..current
instead of this one but I don't know which one that is.
 
J

Jack Jackson

I'm converting from a VBA environment. What event fires when the form is
loaded with the current record, similar to the form..current event in VBA?
I've got a vs project with an mdb that has the path for an image, along with
some other fields. When I open the project, the first record displays just
fine. But when I click on the "move next" button on the binding navigator,
the next record displays but the image doesn't change. When I debug the
code, the path is from the previous record. So it's always one record
behind. Here's a snippet of my code to explain what I mean. This code is in
the BindingNavigatorMoveNextItem_Click event:

If Me.txtImageFileName IsNot DBNull.Value Then
Me.PhotoOrImage.Image = Image.FromFile(Me.txtImageFileName.Text)
End If

txtImageFileName is the text box containing the path name and gets its value
from the mdb.

I assume I need to put this code in an event similar to form..current
instead of this one but I don't know which one that is.

..NET forms don't have any concept like "when a form is loaded with the
current record". What you need is an event that fires when the record
position changes.

I have never used the BindingNavigator, but I think it works in
conjunction with a BindingSource (the BindingNavigator has a
BindingSource property that should be the BindingSource it is using).
The BindingSource has a PositionChanged event that is what I think you
should use.
 
G

Guest

Thanks. That's what I needed.

Jack Jackson said:
..NET forms don't have any concept like "when a form is loaded with the
current record". What you need is an event that fires when the record
position changes.

I have never used the BindingNavigator, but I think it works in
conjunction with a BindingSource (the BindingNavigator has a
BindingSource property that should be the BindingSource it is using).
The BindingSource has a PositionChanged event that is what I think you
should use.
 

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