HighTechTalks DotNet Forums  

How to capture Item's event through an object of its collection in a external class?

Dotnet Framework (CLR) microsoft.public.dotnet.framework.clr


Discuss How to capture Item's event through an object of its collection in a external class? in the Dotnet Framework (CLR) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
planet.creativa@gmail.com
 
Posts: n/a

Default How to capture Item's event through an object of its collection in a external class? - 04-27-2007 , 09:44 AM






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 :-)


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.