473,403 Members | 2,222 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,403 software developers and data experts.

Event is fired multiple times

Hello Everyone,

I am having an issue where an event appears to be fired repeatedly where I
only expect it to be fired once. See below for objects and behaviors.

I have a control that contains a treeview, it creates the TopLevel object
and subscribes to the ObjectChanged Event. When the event is fired, I
rebuild the treeview. If I change data from TopLevelData, the event is
fired just once. When I change data in ChildObject, the event is fired
multiple times. Perhaps the Event doesn't know it was heard and feels the
need to repeat itself.

I am sure I am missing something, anyone have any ideas what that is?

VB2005, WinXP

Here is a sample of what I am doing.

Class TopLevel

Readonly Property TopLevelData
Readonly Property ChildCollection

OnEvent ChildCollection.ListChanged, RaiseEvent ObjectChanged
OnEvent TopLevelData.PropertyChanged, RaiseEvent ObjectChanged

Class TopLevelData

On Property Change, RaiseEvent PropertyChanged

Class ChildCollection (ListOf ChildObject)

On Event ChildObject Property Change, RaiseEvent ListChanged
On Addition or Deletion of ChildObject, RaiseEvent ListChanged

Class ChildObject

On Property Change, RaiseEvent PropertyChanged

Jan 11 '07 #1
2 2525
Random guess since I don't work with treeviews much:

Child object changes - fires event
Top Level object recognizes change of one of it's children, hence a change
to something in it's heiarchy, - fires event.

test: comment out "OnEvent TopLevelData.PropertyChanged, RaiseEvent
ObjectChanged" and modify child object - if only fires once, it give a
pretty good idea


"AMDRIT" <am****@hotmail.comwrote in message
news:uE**************@TK2MSFTNGP06.phx.gbl...
Hello Everyone,

I am having an issue where an event appears to be fired repeatedly where I
only expect it to be fired once. See below for objects and behaviors.

I have a control that contains a treeview, it creates the TopLevel object
and subscribes to the ObjectChanged Event. When the event is fired, I
rebuild the treeview. If I change data from TopLevelData, the event is
fired just once. When I change data in ChildObject, the event is fired
multiple times. Perhaps the Event doesn't know it was heard and feels the
need to repeat itself.

I am sure I am missing something, anyone have any ideas what that is?

VB2005, WinXP

Here is a sample of what I am doing.

Class TopLevel

Readonly Property TopLevelData
Readonly Property ChildCollection

OnEvent ChildCollection.ListChanged, RaiseEvent ObjectChanged
OnEvent TopLevelData.PropertyChanged, RaiseEvent ObjectChanged

Class TopLevelData

On Property Change, RaiseEvent PropertyChanged

Class ChildCollection (ListOf ChildObject)

On Event ChildObject Property Change, RaiseEvent ListChanged
On Addition or Deletion of ChildObject, RaiseEvent ListChanged

Class ChildObject

On Property Change, RaiseEvent PropertyChanged

Jan 11 '07 #2
Thanks for the reply.

I thought of these too, and am still perplexed.

Here is my logic for property set

Dim strTemp As String = pstrInstanceName

If String.Compare(value, strTemp, False) <0 Then
pstrInstanceName = value
Trace.WriteLine(String.Format("Property:{0} changed",
"InstanceName"))
RaiseEvent PropertyChanged(Me, New
PropertyChangedEventArgs("InstanceName", strTemp, pstrInstanceName))
End If

Below is trace log output. I have three actions: Create the TopLevel,
Create a ChildObject, Change a ChildObject property value.

Creating and instantiating the TopLevel Class
----------------------------------------------
Property:ProjectName changed
S T A R T B I N D I N G T R E E
E N D B I N D I N G T R E E

Creating a new BusinessObject object
-------------------------------------
Property:BusinessObjects changed
List:ProjectInfos changed
S T A R T B I N D I N G T R E E
E N D B I N D I N G T R E E
Property:BusinessObjects changed
List:ProjectInfos changed
S T A R T B I N D I N G T R E E
E N D B I N D I N G T R E E
Property:BusinessObjects changed
List:ProjectInfos changed
S T A R T B I N D I N G T R E E
E N D B I N D I N G T R E E

Changing a property value in BusinessObject
-------------------------------------------
Property:InstanceName changed
Property:BusinessObjects changed
List:ProjectInfos changed
S T A R T B I N D I N G T R E E
E N D B I N D I N G T R E E
Property:BusinessObjects changed
List:ProjectInfos changed
S T A R T B I N D I N G T R E E
E N D B I N D I N G T R E E
Property:BusinessObjects changed
List:ProjectInfos changed
S T A R T B I N D I N G T R E E
E N D B I N D I N G T R E E
Property:BusinessObjects changed
List:ProjectInfos changed
S T A R T B I N D I N G T R E E
E N D B I N D I N G T R E E
Property:BusinessObjects changed
List:ProjectInfos changed
S T A R T B I N D I N G T R E E
E N D B I N D I N G T R E E
Property:BusinessObjects changed
List:ProjectInfos changed
S T A R T B I N D I N G T R E E
E N D B I N D I N G T R E E
Property:BusinessObjects changed
List:ProjectInfos changed
S T A R T B I N D I N G T R E E
E N D B I N D I N G T R E E
"Matt F" <mf****************@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Random guess since I don't work with treeviews much:

Child object changes - fires event
Top Level object recognizes change of one of it's children, hence a change
to something in it's heiarchy, - fires event.

test: comment out "OnEvent TopLevelData.PropertyChanged, RaiseEvent
ObjectChanged" and modify child object - if only fires once, it give a
pretty good idea


"AMDRIT" <am****@hotmail.comwrote in message
news:uE**************@TK2MSFTNGP06.phx.gbl...
>Hello Everyone,

I am having an issue where an event appears to be fired repeatedly where
I only expect it to be fired once. See below for objects and behaviors.

I have a control that contains a treeview, it creates the TopLevel object
and subscribes to the ObjectChanged Event. When the event is fired, I
rebuild the treeview. If I change data from TopLevelData, the event is
fired just once. When I change data in ChildObject, the event is fired
multiple times. Perhaps the Event doesn't know it was heard and feels
the need to repeat itself.

I am sure I am missing something, anyone have any ideas what that is?

VB2005, WinXP

Here is a sample of what I am doing.

Class TopLevel

Readonly Property TopLevelData
Readonly Property ChildCollection

OnEvent ChildCollection.ListChanged, RaiseEvent ObjectChanged
OnEvent TopLevelData.PropertyChanged, RaiseEvent ObjectChanged

Class TopLevelData

On Property Change, RaiseEvent PropertyChanged

Class ChildCollection (ListOf ChildObject)

On Event ChildObject Property Change, RaiseEvent ListChanged
On Addition or Deletion of ChildObject, RaiseEvent ListChanged

Class ChildObject

On Property Change, RaiseEvent PropertyChanged


Jan 11 '07 #3

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

Similar topics

2
by: Thomas | last post by:
Hi there I build a class "ButtonClass" with two private Buttons, "OK" And "Cancel". Now, I would like to use this class in a Windowsform for example three times. ButtonClass c1 = new...
2
by: TF | last post by:
hi, i am using a ListBox control on a windows form using VB.Net. when i set the DataSource property of the control to an ArrayList it fires following events in this order: SelectedIndexChanged...
18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
6
by: Tom | last post by:
Hi, In the following code I have reproduced a problem in IE that is extremely annoying for my application. <html> <head> <script type="text/javascript">
3
by: DEK | last post by:
Stepping through my code the click eventhandler code executes through a few times before it finally stops. Even though I only click the button once, is there a reason for this, I have a few if...
2
by: Simon Verona | last post by:
I have a usercontrol with code in the "leave" event which updates the final data back into a database. This works fine except if I have a default "accept" button on a form and invoke it by...
1
by: Jason Richmeier | last post by:
I am experiencing some unexpected behavior with the Form Load event in a Windows application. Hopefully, someone can explain why this behavior is occurring. In my application, I have a form...
2
by: Chuck B | last post by:
I couldn't find the info I was looking for anwhere else so I'll try here. I have a custom control that calls a delegate method when a SelectHandler event is fired. The SelectHandler method adds a...
0
by: das | last post by:
Hello all, I am using the SqlDependency to subscribe to any new inserts into a database table, I enabled the DB to be borker ready and subscrbed to Query notifications on the database. My C#...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.