Events in dot net pogramming, DOT NET Programming

What are events?

As compared to the delegates events works with source and listener methodology. So the listeners who are interested in receiving few events they subscribe to the source. Once this subscription is completed the source raises events to its entire listener when required. One source can have many listeners. In the sample given below class "ClsWithEvents" is an event source class, which has a event "EventAddString()". Now the listeners who are interested in receiving these events they can subscribe to this event. In the 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


Figure:-Events in action

Posted Date: 9/22/2012 3:03:28 AM | Location : United States

Related Discussions:- Events in dot net pogramming, Assignment Help, Ask Question on Events in dot net pogramming, Get Answer, Expert's Help, Events in dot net pogramming Discussions

Write discussion on Events in dot net pogramming
Your posts are moderated
Related Questions
how can i construct er diagram for payroll managment

What is AppSetting Section in "Web.Config" file? Web.config file describe the configuration for a webproject. By Using "AppSetting" section we can define user defined values. T

How inheritance is achieved in VB.NET? The Inheritance is achieved by using "Inherits" keyword in the VB.NET (& For C# it is ":"). Easy Sample is provided in CD for understandi

Develop Skype Recorder Application + Setup + Sourcecode + NICE UI Project Description: i need an application built which will allow user to record skype audio or video calls

What is DCOM? DCOM is different from COM in that it allows for creating objects distributed aroundĀ  a network, and a protocol for invoking that object's methods, & secures the

What is Thread.Join() in threading? There are 2 versions of Thread.Join :- Thread.join(). Thread.join(Integer) this returns a Boolean value. The Thread.Join

How can we know a state of a thread? The "ThreadState" property is used to get complete detail of a thread. The Thread can have one or a combination of status.System.Threading.

Need Experienced dot Net and PHP Programmers Project Description: Need Experienced dot Net., JSP, PHP, Java Programmers Skilled professional and command in Programming eit

What is the difference between int and int32. There is no difference among int and int32. System.Int32 is a .NET Class and int is an alias name for System.Int32.