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 the difference between the Take and Skip clauses? The Take clause returns a specified number of elements. For instance, you can use the Take clause to return two values

Write a Program of Changing String Order - C# Language  using System;   class Prog3_2  {       public static void Main(String [] args)    {     Console.Write(ar

Differences between Datagrid, Datalist and Repeater?   1. Datagrid has paging whereas Datalist doesnt. 2. Datalist has a property called repeat. Direction = vertical/horizon

How do we enable SQL Cache Dependency? Below are some of the steps to enable the SQL Cache Dependency:- Enable the notifications for database. Enable the notificatio

How can we add relation's between table in a DataSet? Dim objRelation As DataRelation  objRelation=New DataRelation("CustomerAddresses",objDataSet.Tables("Customer").Colu

What are benefits & Limitation of  Hidden fields? The benefits of using Hidden fields are as shown below :- 1)    They are very simple to implement. 2)    As the data is

We need a .NET Synchronisation of BugNet -> Paymo -> Insightly We need a small .net utility that is able to synchronise projects as well as tasks between three applications 1

I need Kinect Fitting Room - Smart Fitting Mirror I'm presently looking for someone able to create software exactly like this fitnect (Kinect Fitting Room). Software can work

In what order do the events of an ASPX page execute. As a developer is it important to understand these events?   If you try to access it in Page_Load that is way previous than

Project Description: Specifically i need develop one web based application which have student registration and according to semester and each time it will change as per semester