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
Show the code for the file dependency in cache? Partial Class Default_aspx Public Sub displayAnnouncement() Dim announcement As String If Cache("announcement") Is Noth

Project Description: Online game development 1. Online Live Baccarat Game is required - server program(IOCP or ect..). - 2D graphic design. - client program. - we

What is a host process? A host process is an implementable program that hosts a workflow. It might be a Windows Forms application, a Web application, or a Web service applicati

How do we assign page specific attributes? The Page attributes are specified by using the @Page directive.

Asp.net expert and simple html I am not new to the industry. I am seeking a long term asp.net developer to build and maintain a volleyball player management website. We would

Describe the XmlWriter class. The XmlWriter class is used to write XML to a stream, a file, or a Textwriter object. This class works in a forward-only, non-cached manner. You c

What is the Append Format for FileUpload Control in ASP.Net? What it specify?

How can we perform transactions in .NET? The common sequence of steps that would be performed for developing a transactional application is as follows: 1)In the first step o

This assignment aims to give you a deeper understanding of a 3-tiers integrated application, which groups together several topics taught in this course. This assignment asks yo

Briefly explain the characteristics of reference-type variables that are supported in the C# programming language. The variables that are based on reference types keeps referen