473,386 Members | 1,766 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,386 software developers and data experts.

How do I know my collection was modified?

I have a user control that includes a StringCollection. I provide my users
with a property that retrieves a reference to the string collection so they
can add and remove items from it, just as you would do if this were, for
example, a listbox.

What I can't see is any way for my user control to detect that the
StringCollection was modified. Is there any way (short of overriding all the
methods) that I can be informed if the collection is modified so I can
redraw my control?

Thanks
Steve
Sep 7 '06 #1
3 2720
Doesn't look like you can. I would inherit a new class from
System.Collections.ObjectModel.Collection<Tinstead . That one has proteced
methods that you can override to handle insert, remove and set.

/claes
"Steve Barnett" <no****@nodomain.comwrote in message
news:eY**************@TK2MSFTNGP06.phx.gbl...
>I have a user control that includes a StringCollection. I provide my users
with a property that retrieves a reference to the string collection so they
can add and remove items from it, just as you would do if this were, for
example, a listbox.

What I can't see is any way for my user control to detect that the
StringCollection was modified. Is there any way (short of overriding all
the methods) that I can be informed if the collection is modified so I can
redraw my control?

Thanks
Steve

Sep 7 '06 #2
Much appreciated - I thought it was just me being dumb. I'll go with your
suggestion.

Thanks
Steve
"Claes Bergefall" <lo*****@nospam.nospamwrote in message
news:eo****************@TK2MSFTNGP04.phx.gbl...
Doesn't look like you can. I would inherit a new class from
System.Collections.ObjectModel.Collection<Tinstead . That one has
proteced methods that you can override to handle insert, remove and set.

/claes
"Steve Barnett" <no****@nodomain.comwrote in message
news:eY**************@TK2MSFTNGP06.phx.gbl...
>>I have a user control that includes a StringCollection. I provide my users
with a property that retrieves a reference to the string collection so
they can add and remove items from it, just as you would do if this were,
for example, a listbox.

What I can't see is any way for my user control to detect that the
StringCollection was modified. Is there any way (short of overriding all
the methods) that I can be informed if the collection is modified so I
can redraw my control?

Thanks
Steve


Sep 7 '06 #3
"Steve Barnett" <no****@nodomain.comwrote in message
news:O8**************@TK2MSFTNGP06.phx.gbl...
Much appreciated - I thought it was just me being dumb. I'll go with your
suggestion.

Thanks
Steve
"Claes Bergefall" <lo*****@nospam.nospamwrote in message
news:eo****************@TK2MSFTNGP04.phx.gbl...
>Doesn't look like you can. I would inherit a new class from
System.Collections.ObjectModel.Collection<Tinstea d. That one has
proteced methods that you can override to handle insert, remove and set.

/claes
You may try BindingList<Tinstead, and subscribe to the ListChanged event
Sep 7 '06 #4

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

Similar topics

18
by: Scott | last post by:
I have a collection where the items in the collection are dates. I want to iterate over the collection and build a value list string for the rowsource of a listbox. The dates in the collection are...
3
by: Grandma Wilkerson | last post by:
Hi, The documentation states that enumeration through a collection is inherently NOT thread-safe, since a thread which added/removed an item from said collection could screw up the thread that...
5
by: David C | last post by:
This is very strange. Say I have code like this. I am simply looping through a collection object in a foreach loop. Course course = new Course(); foreach(Student s in course.Students) {...
2
by: Brian | last post by:
NOTE ALSO POSTED IN microsoft.public.dotnet.framework.aspnet.buildingcontrols I have solved most of my Server Control Collection property issues. I wrote an HTML page that describes all of the...
3
by: Jeff L. | last post by:
I have an interesting problem and I'm not coming up with any answers in my searches, so hopefully someone can give me a hand with this. I have a feeling it's easy, but I usually get my nose stuck...
9
by: bonk | last post by:
Does anyone have a simple example on how to prohibit that any thread other than the current thread modifies a certain object (a collection) while we are in a certain section of the code? In other...
0
by: Geoffrey | last post by:
Hello, I work with .net remoting,to simplify, when the client connected, he send an handle to an object, the object is used to exchange message and events. no problem. In my server, I keep a...
5
by: sstory | last post by:
I have a class in vb.net that Inherits Generic.List(Of myclass) I want to have totals in this class that are static...i.e. not recalculated every time. They should be calculated once and never...
1
by: Michel Racicot | last post by:
When executing the following function, I get this error message: Collection was modified; enumeration operation may not execute. The only thing that can modify lstClients is when I add one in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.