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

2484_Event.png

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
Question 1 A small Canadian law firm specializing in immigration law has what it considers a successful website. One of the most popular features of the website is its newslet

Which are the namespaces in localization and globalization? There are 2 most important namespaces:- 1)System.Globalization - It contains classes that define culture-relate

I want help to make Clone a Website -dior.com I want all features of above mentioned site 1)Effects 2)Mobile optimization for mobile browsers of all smart phones. Etc.

What's the difference between localization and globalization? Globalization: The Globalization is a process of developing a program core whose features and code design are no

What is Difference between NameSpace and Assembly? Following are the differences among namespace and assembly: Assembly is physical grouping of logical units, Namespace, log

Describe the various components in sequence diagrams. Object lifeline: - It shows the lifetime of an object creation and its destruction. If the object is created or des

What is the main difference between sub-procedure and function? The sub-procedure is a block of multiple visual basic statements within Sub and End Sub statements. It is used t

Why The JavaScript Validation Not Run on the Asp.Net? The Asp.Net Button Is post backed on the server & not yet Submit & when It goes to the server its states is lost so if we

Project Description: We are seeking experienced .NET developers (possibly certified) to work with us on several future projects. You will have to pass a simple test to be consid

Project Description: College erp Erp key features: Panacea ERP Online Suite is server based college based management software. Gives Password facility for different use