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
What is UDDI? The Full form of the UDDI is Universal Description, Discovery and Integration. The directory that can be used to publish and discover public Web Services. If you

What is "Common Language Runtime" (CLR)?  CLR is .NET equivalent of Java Virtual Machine (JVM). It is the runtime that changes a MSIL code into the host machine language code,

Explain ADO.NET in brief. ADO.NET is a very significant feature of .NET Framework, which is used to work with data that is stored in structured data sources, like databases and

How to decide on the design consideration to take a Datagrid, datalist or repeater? So many make a blind choice of choosing datagrid directly, but that is not the right way.

What are the improvements made in CAS in .NET 4.0? The CAS mechanism in .NET is used to control and configure the ability of managed code. Previously, as this policy was applic

What is a delegate? A delegate is similar to a class that is used for storing the reference to a method and invoking that method at runtime, as needed. A delegate can hold the

What is the difference amonga system workflow and a human workflow? A system workflow is a workflow that is developed to automate interactions between applications. Such workfl

want to generate random numbers between 1-15 and no one should repeat until all numbers have come once....

What is "Common Type System" (CTS)?  CTS define all of the basic types that can be used  in the .NET Framework and the operations performed on those type. All this time we have

I am looking individuals who have company experience working on Jquery and Microsoft Technology ( MVC 4.5 ), who will take live online session and provide training through Team Vie