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 Discuss the following with respect to .NET Technologies Web Applications Web Server Connections Question 2 Write a sample program using ASP.NET explain

Which command-line tool generates code and mapping for the LINQ to SQL component of .NET Framework? The SqlMetal.exe command-line tool generates code and map the LINQ to SQL co

Custom Login Page for SharePoint 2013 with Active Directory Project Description: I would like to prepare a webpart or an application for Sharepoint 2013 foundation. The we

i am working on an project and my client needs it in 2 days.project is ready but don''t know how to make setup project including local sql database(.mdf) included in setup..

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

Development Executive of DataFlow System, We started by initially providing our customers with customized ITES solutions and IT. We have now expanded our services which add QA s

What are the authentication methods in .NET? 1.Windows authentication 2.Forms authentication 3.Passport authentication 4.None/custom authentication

Xlsx/Csv File Reader Need C# MVC coder that will do the following- Take a filepath for an online xlsx, xls or csv file (must be able to handle each of these formats) as well

Can a .NET web application consume Java web service? Yes Offcourse.Actually Webservices are independent  to language. It depends on WSDL and SOAP. so any one can develope the W

What is difference between System.String and System.StringBuilder classes? String and StringBuilder classes are used to store string values but the dissimilarity in them is tha