Why this no work 
Author Message
 Why this no work

I am trying to create an event handler so that when the user moves to
another row in a certain table I can be notified of it.  I have read a lot
but apparently am missing something.  I have the following code in the
form_load event for my Winform

AddHandler DsInvHrsPaid1.Tables("Invoices").RowChanging, _
                (New Data.DataRowChangeEventHandler _
                (AddressOf Me.TempTest01))

I have a Sub routine as follows:

Private Sub TempTest01(ByVal InvoicesSender As Object, _

ByVal EventData As Data.DataRowChangeEventArgs)

Throw New Exception("I am moving from row to row")

End Sub

I would have guessed that as a result of the code above that I would have
been notified when the user moves from row to row but I am not.

Could someone advise?



Tue, 20 Sep 2005 08:33:18 GMT  
 Why this no work

Quote:
> I am trying to create an event handler so that when the user
> moves to another row in a certain table I can be notified of it.
>  I have read a lot but apparently am missing something.  I have
> the following code in the
> form_load event for my Winform

> AddHandler DsInvHrsPaid1.Tables("Invoices").RowChanging, _
>                 (New Data.DataRowChangeEventHandler _
>                 (AddressOf Me.TempTest01))

> I have a Sub routine as follows:

> Private Sub TempTest01(ByVal InvoicesSender As Object, _

> ByVal EventData As Data.DataRowChangeEventArgs)

> Throw New Exception("I am moving from row to row")

> End Sub

> I would have guessed that as a result of the code above that I
> would have been notified when the user moves from row to row but
> I am not.

> Could someone advise?

How do you "move" from row to row?? There's no current row. You can access
the row by index. RowChanging fires when the row changes, not when the user
moves (wherever).

Armin



Tue, 20 Sep 2005 09:08:35 GMT  
 Why this no work

Quote:
> How do you "move" from row to row??

I move from row to row with navigational buttons.  My MoveNext button
contains code that looks like this:

Private Sub MoveNext()
        With Me.BindingContext(DsInvHrsPaid1, "Invoices")
            If .Position = (.Count - 1) Then
                Beep()
            Else
                .Position += 1
                PositionChanged()
            End If
        End With
End Sub



Tue, 20 Sep 2005 09:33:03 GMT  
 Why this no work

Quote:
> > How do you "move" from row to row??

> I move from row to row with navigational buttons.  My MoveNext
> button contains code that looks like this:

> Private Sub MoveNext()
>         With Me.BindingContext(DsInvHrsPaid1, "Invoices")
>             If .Position = (.Count - 1) Then
>                 Beep()
>             Else
>                 .Position += 1
>                 PositionChanged()
>             End If
>         End With
> End Sub

You didn't mention that you use data bound controls. Seems like the
PositionChanged event is what you're looking for.

Armin



Tue, 20 Sep 2005 09:45:48 GMT  
 Why this no work
Well I don't mean to be a pain but this doesn't answer my question.  The
question is how do I trap for the user moving from row to row using data
bound controls.  Sorry I didn't mention that these are data bound controls
earlier.

You mention that the PositionChanged event is what I am looking for.  I
assume there is some built-in VS event called PositionChanged and not the
sub routine I created in my code (see below) called PositionChanged.  If so,
how do I make use of it and implement it in my code?

When the user moves from one row to another I would like to trap for it so I
can do something.


Quote:

> > > How do you "move" from row to row??

> > I move from row to row with navigational buttons.  My MoveNext
> > button contains code that looks like this:

> > Private Sub MoveNext()
> >         With Me.BindingContext(DsInvHrsPaid1, "Invoices")
> >             If .Position = (.Count - 1) Then
> >                 Beep()
> >             Else
> >                 .Position += 1
> >                 PositionChanged()
> >             End If
> >         End With
> > End Sub

> You didn't mention that you use data bound controls. Seems like the
> PositionChanged event is what you're looking for.

> Armin



Wed, 21 Sep 2005 01:47:10 GMT  
 Why this no work

Quote:
> Well I don't mean to be a pain but this doesn't answer my
> question.  The question is how do I trap for the user moving
> from row to row using data bound controls.  Sorry I didn't
> mention that these are data bound controls earlier.

> You mention that the PositionChanged event is what I am looking
> for.  I assume there is some built-in VS event called
> PositionChanged and not the sub routine I created in my code
> (see below) called PositionChanged.  If so, how do I make use of
> it and implement it in my code?

> When the user moves from one row to another I would like to trap
> for it so I can do something.

Menu Edit -> Search -> Symbol search: PositionChanged

I haven't used data bound controls so far, but when I look at the object
browser, you can add a Binding object to the Databindings collection of a
control. A Binding object has a BindingManagerBase property, and a
BindingManagerBase object has a PositionChanged event.

So, when I take parts of your code:

Addhandler Me.BindingContext(DsInvHrsPaid1, "Invoices").PositionChanged, _
AddressOf <YourEventHandler>

Armin



Wed, 21 Sep 2005 02:21:21 GMT  
 Why this no work

Quote:
> Menu Edit -> Search -> Symbol search: PositionChanged

I see no menu items as you describe.  Do you mean Edit Menu, Find & Replace,
Edit Symbol?

Quote:
> I haven't used data bound controls so far,

If you haven't used data bound controls yet, perhaps someone else could
chime in here and give an answer.

The line below does not work for me:

AddHandler Me.BindingContext(DsInvHrsPaid1, "Invoices").PositionChanged, _
            (AddressOf  TempTest02)

There is a squiggly line under TempTest02.  I suppose this is because I do
not have the proper arguments in TempTest02.  I think the problem is with
the second argument.  I do not know what to put in the second argument.

Private Sub TempTest02(ByVal HoursSender As Object, _
        ByVal EventData As xxxx )

End Sub

Would you or somone one advise?



Wed, 21 Sep 2005 03:37:00 GMT  
 Why this no work


Quote:

> Private Sub TempTest02(ByVal HoursSender As Object, _
>         ByVal EventData As xxxx )

> End Sub

> Would you or somone one advise?

It needs to match the signature of the PositionChanged event which is:

PositionChanged(ByVal HoursSender As Object, ByVal EventData As
System.EventArgs)

--
If you don't like lunchmeat, please remove it from my e-mail address to
send me an e-mail



Wed, 21 Sep 2005 04:17:12 GMT  
 Why this no work

Quote:
> > Menu Edit -> Search -> Symbol search: PositionChanged

> I see no menu items as you describe.  Do you mean Edit Menu,
> Find & Replace, Edit Symbol?

Sorry, I've the German version. ;) Yes, might be Edit -> Find & Replace,
then the last menu item. Well, I usually press Alt+Ctrl+Shift+F12.

Quote:
> > I haven't used data bound controls so far,

> If you haven't used data bound controls yet, perhaps someone
> else could chime in here and give an answer.

> The line below does not work for me:

> AddHandler Me.BindingContext(DsInvHrsPaid1,
> "Invoices").PositionChanged, _
>             (AddressOf  TempTest02)

> There is a squiggly line under TempTest02.  I suppose this is
> because I do not have the proper arguments in TempTest02.  I
> think the problem is with the second argument.  I do not know
> what to put in the second argument.

> Private Sub TempTest02(ByVal HoursSender As Object, _
>         ByVal EventData As xxxx )

> End Sub

> Would you or somone one advise?

You can also open the object browser and click the  icon at the top called
"find symbol" (or whatever it's called in English). When you've found the
Event, the argument's are described. You can also find it in the
documentation.

The arguments are: ByVal sender As Object, ByVal e As System.EventArgs

Armin



Wed, 21 Sep 2005 03:58:06 GMT  
 Why this no work
Thank You.   That was the answer.


Wed, 21 Sep 2005 07:55:50 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Why oh why doesn't this work?

2. Why LoadPicture() works on local pathes and doesn't work on the URLS

3. Why DCOM ActiveX Exe is Working and ActiveX Dll is not working

4. why why why why

5. Why why why why?

6. Why Why Why

7. ActiveX wont deploy to Win 2K - why, Why WHY

8. VB6 ListView: Why oh why oh why...

9. Why, Why, Why!!!!!!!!!!!

10. !Excel/VB: why why why?

11. Why,Why,Why are javabeans completely ignored?

12. VB6 ListView: Why oh why oh why...

 

 
Powered by phpBB® Forum Software