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
Develop a windows desktop application Project Description: I am looking to get a desktop application developed. The desktop application will have the subsequent few features:

Prepare an Application in C# or C++ Project Description: We are seeking someone who can write a program in C# or C++. The concept is to develop the program using a Cross P

Explain assemblies An assembly is a single deployable unit that having all the information about the implementation of : - classes - structures and - interfaces An

What is V model in testing? The V model map's the type of test to the stage of development in the project. Figure: - V Model 1) Unit Testing: The Starting fro

Develop Outlook Add-In for all versions I need simple code for Outlook(express,2003,2007,2010,2013) Add-In with functionality to repeatedly send CC to the specified email(s), th

What is a class? A class explains all the attributes of objects, as well as the methods that execute the behavior of member objects. It is a comprehensive data type, which show

Mention different types of data providers available in .NET Framework. .NET Framework Data Provider for SQL Server - Give access to Microsoft SQL Server 7.0 or later version. I

Can you give an overview of ADO.NET architecture? The most important part  in the ADO.NET architecture is the "Data Provider". The  Data Provider provides access to the datasou

Calculate Standard Deviation - C# Program Hello i am unable to find the code for Calculate Standard Deviation in c#. Can anybody please provide me the assignment help?

What are benefits and Limitation of using Viewstate for state management The benefits of using Viewstate are as follows:- 1)    There is no server resources required because