Re: Newbie question about form events
by Jack Jackson on 11/1/2007 10:21:00 AM
On Thu, 1 Nov 2007 14:02:00 -0700, EManning
<EManning@discussions.microsoft.com> wrote:
>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.