473,769 Members | 5,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Raising Events From Objects In A Collection

IN vb.Net

Class clsCommande Inherits CollectionBase

and

Class clsProduct

clsCommand contain a IList of clsProduct
the clsProduct.Quan tity property Raise an Event : Events ProductModify() .

- How can I trap this event in clsCommande ?

_______________ _______________ ____
Franky
Franky_NOSPAM_@ Boucher_NOSPAM_ os.com

Nov 20 '05 #1
3 2020
In article <#D************ **@TK2MSFTNGP10 .phx.gbl>, Franky wrote:
IN vb.Net

Class clsCommande Inherits CollectionBase

and

Class clsProduct

clsCommand contain a IList of clsProduct
the clsProduct.Quan tity property Raise an Event : Events ProductModify() .

- How can I trap this event in clsCommande ?

_______________ _______________ ____
Franky
Franky_NOSPAM_@ Boucher_NOSPAM_ os.com


If I'm understanding you correctly, you have a strongly typed collection
of a class that raises an event that you want the collection to catch...
If that's the case, then you'll want to just dynamically add and remove
the event handlers as the objects are added and removed from your
colleciton...

Public Function Add (ByVal value As clsProduct) As Integer
AddHandler value.ProductMo dify, AddressOf Me.EventHandler Method
Return Me.List.Add(val ue)
End Function

' you'll of course want to make this match what ever your signature is,
' but you might at least want to make sure the object parameter is there
' so you can tell which object raised the event
Private Sub EventHandlerMet hod (ByVal sender As clsProduct, ByVal e As
EventArgs)

End Sub

Public Sub Remove (ByVal value As clsProduct)
RemoveHandler value.ProductMo dify, AddressOf Me.EventHandler Method
Me.List.Remove( value)
End Sub
Anyway, that is a basic off the cuff sketch to get you going.
--
Tom Shelton [MVP]
Nov 20 '05 #2
I think that Tom Shelton's suggestion would probably work.
But you might want to further define the relationship of the clsProduct to the
Collection.
Will clsProduct always belong to this type of Collection, or could it exist
outside the collection?
Could it exist in a different collection?
Do other objects besides the collection need to respond to Events from
clsProduct?
Basically, I'm trying to determine if a common Parent/Child relationship exists.
If that is the case, IMHO Events would be an inefficient way to go.
Hooking / Unhooking Events can be time consuming, you have no guarantee of when
the Event will be processed and/or which order, etc.
If a true Parent/Child relationship exists, then I would add a Parent property
to the clsProduct and assign it to the Collection when Adding. And of course
unassigning if removing.
Then when the Child is modified, it could just directly call an appropriate
method on the Parent.
This can be easily achieved using strongly typed parameters, or with Interface
Implementation.

Say a Child is modified, it could call the ChildModified Sub on it's parent.

clsProduct.Quan tity changes, then in the Quantity property it could call
me.Parent.Child Modified(me)

I know that explanation was a little dis-jointed, but hopefully it made sense.

Gerald
"Franky" <fr************ ***@hotmail.com > wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
IN vb.Net

Class clsCommande Inherits CollectionBase

and

Class clsProduct

clsCommand contain a IList of clsProduct
the clsProduct.Quan tity property Raise an Event : Events ProductModify() .

- How can I trap this event in clsCommande ?

_______________ _______________ ____
Franky
Franky_NOSPAM_@ Boucher_NOSPAM_ os.com

Nov 20 '05 #3
Hi,

I figured out by searching through the Registry the command to start a database: "c:\Program Files\Sybase\SQ L Anywhere 9\win32\dbsrv9. exe -hvASANYs_gwsrv" . I am using Seagate Backup Exec 7.2 (1998) on a Windows NT server. There is an option to run a command script BEFORE and AFTER the backup. I need to know the command script to STOP the database so that the database can be included in the backup. THANKS!

From http://search.yahoo.com/search?p=cls...fp-t-417&x=wrt

Posted via DevelopmentNow. com Groups
http://www.developmentnow.com
Sep 18 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1885
by: Bob | last post by:
Is there an interface or events in the system that occurs pre and post garbage collection that one of my objects can attach to? I need to know in my application when garbage collection is about to take place and when it has completed. This is to make sure a system critical event does not happen while the application is frozen, if it freezes for longer than 2 seconds. Thanks!
2
3012
by: Krzysztof Malinowski | last post by:
Hi, We can raise an event by calling some method the same like a delegate. Actually one event can reference a few different method each of these meets delegate declaration. Like below: (...) clock.Alarm += new AlarmEventHandler(w.AlarmRang); (...)
2
9199
by: Jon Davis | last post by:
The garbage handler in the .NET framework is handy. When objects fall out of scope, they are automatically destroyed, and the programmer doesn't have to worry about deallocating the memory space for those objects. In fact, all the programmer has to worry about is the total sum of objects loaded into RAM at any known point. Memory leaks are not a problem. .... So one would like to think. The reality is that delegates and event...
15
2097
by: Rhy Mednick | last post by:
I have a class (let's call it ClassA) that I've written which has events. In another class (let's call it ClassB) I create a collection of ClassA objects. In a third class (ClassC) I create a reference to some of the ClassA objects created in ClassB. In ClassC I hook into the ClassA events with a foreach loop so that I hook each object. The code is something like this: class ClassC { void SomeMethod() { foreach (ClassA item in...
6
2881
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a TimerState object similar to the example in the System.Threading.Timer documentation. The method which handles the timer events, among other things, periodically calls a method in this TimerState object which raises an event to the startup form,...
7
2444
by: cider123 | last post by:
I'm coding a project using the following article as reference: http://www.codeproject.com/csharp/DynamicPluginManager.asp In this type of project, plugins are loaded dynamically into a Plugin Manager. Your main application then hooks into the Plugin Manager. What I'm trying to figure out is how to impliment some form of raising
4
1597
by: Dave A | last post by:
I am developing a somewhat complex component at the moment and coincidently I am also reading the Framework Design Guidelines book. After reading the section about event raising I have re-written the way my component raises events to follow the Framework Design Guides verbatim; ie (object sender, EventArgs (or some subclass there of) e). The thing that was not explained is why should I need to cast the sender to 'object' when I know...
1
1889
by: Asko Telinen | last post by:
Hi all. I ran into quite strange problem concerning the event raising inside FileSystemWatcher Delete event. First, i would like to describe a bit my environment. I have main GUI application, which uses other class libraries. One lib, called Utils.dll contains custom collection implementation. This simple collection just overrides Add and Remove methods to raise
7
1928
by: nick.fletcher | last post by:
I have a custom collection which derives from Collection<which stores a number of objects. Before each item is added to the collection - an event which it exposes is hooked by the collection and the re-fired to its parent. eg class MyCollection : Collection<MyType> { public AddAnObject(MyType obj)
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9979
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9849
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7393
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5433
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3948
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.