Home All Groups Group Topic Archive Search About

How to capture events fired from objects in collection

Author
13 Apr 2005 6:23 PM
moondaddy
I have a class (myClass) that used to reference a business class (myObj)
using With Events so when myObj raised the event TestEvent, myClass received
it like this

Private Sub myObj_TestEvent (ByVal someVal As String) Handles
myObj.TestEvent

End Sub

Now I created a bindable list class (oList) which contains a collection of
myObj and myClass now reverences oList instead of myObj.

oList Imports System.ComponentModel, Inherits CollectionBase and Implements
IBindingList.

How can I raise the event TestEvent in myObj and receive it in myClass via
oList?

Thanks!!!


--
moondaddy@nospam.nospam

Author
13 Apr 2005 6:22 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"moondaddy" <moondaddy@nospam.nospam> schrieb:
>I have a class (myClass) that used to reference a business class (myObj)
>using With Events so when myObj raised the event TestEvent, myClass
>received it like this
>
> Private Sub myObj_TestEvent (ByVal someVal As String) Handles
> myObj.TestEvent
>
> End Sub
>
> Now I created a bindable list class (oList) which contains a collection of
> myObj and myClass now reverences oList instead of myObj.
>
> oList Imports System.ComponentModel, Inherits CollectionBase and
> Implements IBindingList.
>
> How can I raise the event TestEvent in myObj and receive it in myClass via
> oList?


Take a look at 'RaiseEvent' and 'AddHandler'/'RemoveHandler' in the
documentation.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
13 Apr 2005 7:44 PM
moondaddy
Thanks.  I made a sample project with the code that passes the event through
the colletion to the top level object for anyone who's interested.

--
moondaddy@nospam.nospam
Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:ePy1vWFQFHA.2972@TK2MSFTNGP14.phx.gbl...
> "moondaddy" <moondaddy@nospam.nospam> schrieb:
>>I have a class (myClass) that used to reference a business class (myObj)
>>using With Events so when myObj raised the event TestEvent, myClass
>>received it like this
>>
>> Private Sub myObj_TestEvent (ByVal someVal As String) Handles
>> myObj.TestEvent
>>
>> End Sub
>>
>> Now I created a bindable list class (oList) which contains a collection
>> of
>> myObj and myClass now reverences oList instead of myObj.
>>
>> oList Imports System.ComponentModel, Inherits CollectionBase and
>> Implements IBindingList.
>>
>> How can I raise the event TestEvent in myObj and receive it in myClass
>> via
>> oList?
>
>
> Take a look at 'RaiseEvent' and 'AddHandler'/'RemoveHandler' in the
> documentation.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
>

[attached file: 2005-04-13_Collection_WithEvents.zip]