473,396 Members | 1,923 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Multiple Objects Event Handlers?????

hi,
that's my problem. I have an object and this have a onConnectionChanged
event. and when i use it on ny form i have also my event handler.

Now, my user can add many of this objects to a list ( that is rappresented
graphically by a listview), and each ListItem have in the tag property the
corresponding object. If i add manually a single object on my form.. i write
down manually the eventhandler for that object.. but.. how can i do.. if
objects are addd by a user.. and every object need his event handler???

p1.OnConnectionStatusChanged +=new
ConnectionStatusChangedEventHandler(p1_OnConnectio nStatusChanged);

I need his for many objects.

Gianmaria
Nov 16 '05 #1
1 1803
Hi Gianmara,

It's not entirely clear to me what you are trying to do, but if you automatically need to assign an event handler to run time objects:

1. Use the same eventhandler for all the objects.
2. Determine which object is used from the sender object.

for(int i = 0; i < 20; i++)
{
MyObject o = new MyObject();
o.SomeEvent += new SomeEventHandler(MyEventHandler);
// store o in some collection
}

private void MyEventHandler(object sender, SomeEventArgs e)
{
MyObject p = (MyObject)sender;
// p's status is changed
}

You can use the same event handler for as many object as you need.

--
Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2

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

Similar topics

16
by: sirsean | last post by:
Hi all. I'm trying to dynamically build menus and objects after my page loads. Data is stored in an XML file and is parsed at runtime into Javascript objects. At the moment, I'm working on creating...
106
by: xtra | last post by:
Hi Folk I have about 1000 procedures in my project. Many, many of them are along the lines of function myfuntion () as boolean on error goto er '- Dim Dbs as dao.database Dim Rst as...
8
by: Dennis C. Drumm | last post by:
I have a class derived from a SortedList called SystemList that contains a list of objects indexed with a string value. The definition of the objects contained in the SortedList have a boolean...
15
by: Iced Crow | last post by:
In C# I know that you can use delegates to assing multiple addresses of sub and functions to a delegate and have it fire multiple procedures... How do I do this in VB? I only know of assigning...
6
by: Peter M. | last post by:
Hi all, If an event has multiple subscribers, is it possible to cancel the invocation of event handlers from an event handler? Or to be more specific: I'm subscribing to the ColumnChanging...
3
by: Retep | last post by:
Hi all, hopefully someone can answer the following mystery for me: I have the following (simplified) application setup: Main Form | Form |
1
by: Christian Sengstock | last post by:
Hi all, i have a js application with several event handlers which i manage via prototype .bindAsEventListener. On normal page navigation ( link navigation ) i finish all events handlers...
7
by: Dom | last post by:
In CSharp, can you have multiple handlers for a single event? For example, for a textbox TextChanged event, can I have two separate handlers called up? I have 4 text boxes, and the TextChanged...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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...

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.