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
System Simulation - repost 2 Project Description: A. Prepare random numbers of the form: Case 1: Uniformly distributed random numbers (RNs) [range: 0.0-1.0] Case 2: Exp

Construct a .NET wrapper for a C++ Dll - repost Project Description: We have a classic VC++ Dll (source code of DLL not required) that requires a .NET wrapper built by you. U

I want Windows 8.1 Metro style app development Project Description: I want Windows 8 & 8.1 metro style app development - Media Player application Skills required are C# Pr

What is cyclomatic complexity and why is it important? Cyclomatic complexity is a computer science metric (measurement) developed by Thomas McCabe used to generally calculate t

Generate Function to Create Signed_Body for Instagram Project Description: I want the exact Signed_Body for Instagram The only difference is that I want the most recent ve

Project Description: I need to get lync server 2013 fixed the issues it has hit: 1) Can't connect to it outside network, I think small firewall problem with a little issue in

Explain memory-mapped files. Memory-mapped files (MMFs) permit you map the content of a file to the logical address of an application. These files enable the multiple processes

In What scenarios you use a DOM parser and SAX parser? 1) If you do not require all the data from the XML file then SAX approach is most preferred than DOM as DOM can quiet mem

What are shared (VB.NET)/Static(C#) variables? Shared/Static classes are used when a class gives functionality which is not specific to any instance. In brief if you want an ob

What is the use of DataView? User-defined view of a table is contained in a DataView. A complete table or a small section of table depending on some criteria can be shown by an