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
I need Windows Phone App (WP 8 and above) I am seeking an app developer/designer to develop me a Windows Phone app. This will be an app where users will post questions in the

Need Data Stream from Laptop to Phone Project Description: I have a notepad file that is automatically generated in a set file name and format by acquisition software and wri

Project Description: We require some routines written in C# (.NET) to: * Parse several RESTful APIs to change and push data to RabbitMQ * Pop objects from RabbitMQ and inp

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..

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

Difference between VB.NET and C# This is the main debatable issue in .NET community and everyone treat their languages like religion. It is a very important matter which lan

How does output caching work in ASP.NET?    Output caching is a powerful method that enhances request/response throughput by caching the content generated from dynamic pages. O

Project Description: Program or Fan Page Poster for facebook fan pages. Major task of this program would be posting pictures on your facebook fan page from other users fan pa

Project Description: I am having a table available in excel format and features the subsequent: - It has about 170000 rows - Some text is longer than 255 in length. - S

Live Chat Similar to Alibaba seller/ buyer chat Project Description: I want someone to design and implement for us a live chat program that will be used on our ecommerce webs