Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
What are events
What are events ?
✍: Guest
As compared to delegates events works with source and listener methodology. So listeners
who are interested in receiving some events they subscribe to the source. Once this
subscription is done the source raises events to its entire listener when needed. One
source can have multiple listeners.
In sample given below class “ClsWithEvents” is a event source class, which has a event
“EventAddString()”. Now the listeners who are interested in receiving this events they
can subscribe to this event. In class “FrmWithEvents” you can see they handle clause
which is associated with the “mobjClsWithEvents” objects.
Public Class ClsWithEvents Event EventAddString(ByVal Value As String) Public Sub AddString() RaiseEvent EventAddString(“String added by Event”) End Sub End Class Public Class FrmWithEvents Inherits System.Windows.Forms.Form Private WithEvents mobjClsWithEvents As New ClsWithEvents() Private Sub FrmWithEvents_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub mobjClsWithEvents_EventAddString(ByVal Value As String) Handles mobjClsWithEvents.EventAddString LstData.Items.Add(Value) End Sub Private Sub CmdRunEvents_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdRunEvents.Click mobjClsWithEvents.AddString() End Sub End Class
Nore:- Above source code is provided in “WindowsEvent”
2007-10-23, 5639👍, 0💬
Popular Posts:
.NET INTERVIEW QUESTIONS - How to prevent my .NET DLL to be decompiled? By design .NET embeds rich M...
What metrics will you look at in order to see the project is moving successfully? Most metric sets d...
What is thread? A thread is an independent path of execution in a system.
Can one change the mouse pointer in Forms? The SET_APPLICATION_PROPERTY build-in in Oracle Forms all...
What is the significance of Finalize method in .NET? .NET Garbage collector does almost all clean up...