You posted this question to a C# newsgroup but used VB code...
I would suggest either creating a new EventArgs-derived class to contain the
key object that is the instigator, or use the sender parameter...
--
Browse
http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"(E-Mail Removed)" wrote:
> There are two classes
> 1) Key - contains some public variables, one method "Reset" and one
> event "valuesReset" which is raised by Reset method.
> 2) Keys - this class is collection of objects of class 'Key' and it is
> inherited with ReadOnlyCollection(Of key).
> I'm pasting the code here
>
> Class key
> Public Event valuesReset()
>
> Public _name As String = ""
> Public _title As Integer = 0
> Public _strong As Integer = 0
> Public _italic As Integer = 0
>
> Public Function reset() As Boolean
> _name = ""
> _title = 0
> _strong = 0
> _italic = 0
>
> RaiseEvent valuesReset()
> End Function
> End Class
>
> 'Collection of key
> Class keys
> Inherits ReadOnlyCollection(Of key)
>
> Friend Sub New()
> MyBase.New(New List(Of key))
> End Sub
>
> Friend Function add(ByVal tmpKey As key) As Integer
> If Items.Contains(tmpKey) Then
> Return Items.IndexOf(tmpKey)
> End If
>
> Items.Add(tmpKey)
> Return Count - 1
> End Function
>
> Friend Sub AddAt(ByVal tmpKey As key, ByVal index As
> Integer)
> If index < 0 OrElse index > Items.Count - 1 Then
> Return
> End If
> If Contains(tmpKey) Then
> Return
> End If
>
> Items.Insert(index, tmpKey)
> End Sub
>
> Friend Sub Dispose()
> For i As Integer = Count - 1 To 0 Step -1
> Me(i).reset()
> Next
> End Sub
> Friend Sub remove(ByVal tmpKey As key)
> Items.Remove(tmpKey)
> End Sub
> End Class
>
> Class Form1
> withevents objKeys as Keys
>
> ' I want to capture the "valuesReset" event here with
> the index number of the key type
> ' bject
>
> End Class
>
> Now the problem is how can I capture the event "valuesReset" of an key
> object if I use
> "withevents objKeys as Keys" in any form/outside class? and if it is
> possible how can I know which key object inside the collection has
> raised the event? Thanks In advance :-)
>
>