Addhandler & Collections

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a collection of objects. The objects gather data from separate sources. Once they get data they raise an event called GotData. I want the collection to raise an event whenever any of it's items raises an event. I have trimmed down the code to the relevent areas. I figure I have to add a handler for each item added to the collection, but I cannot figure out how the pass the parameter in the GotData event to the collection so it can pass the data in its event.

Class Gette
Event GotData(ByVal TheData As String

Private Sub ShowData(ByVal SomeData as String
RaiseEvent GotData(SomeData
End Su

End Clas

Class GetterCo
Dim col As New Hashtabl
Event GotSome(ByVal TheData as String

Public Sub AddGetter(ByVal key as String, ByVal itm as Getter
col.Add key, it
AddHandler itm.GotData, AddressOf RaiseDataEvent(???
End Su

Private Sub RaiseDataEvent(???
RaiseEvent GotSome(???
End Su

End Class
 
bdring said:
Class GetterCol
Dim col As New Hashtable
Event GotSome(ByVal TheData as String)

Public Sub AddGetter(ByVal key as String, ByVal itm as Getter)
col.Add key, itm
AddHandler itm.GotData, AddressOf RaiseDataEvent(???)

AddHandler itm.GotData, AddressOf RaiseDataEvent
End Sub

Private Sub RaiseDataEvent(???)

Private Sub RaiseDataEvent(ByVal TheData As String)
RaiseEvent GotSome(???)

RaiseEvent GotSome(TheData )
End Sub

End Class


Don't forget to call RemoveHandler when the item is removed from the
collection.
 
Yes, I know...thanks. There is a lot of missing code. I trimmed it down to the problem area.
 
Back
Top