PC Review


Reply
Thread Tools Rate Thread

How do I know my collection was modified?

 
 
Steve Barnett
Guest
Posts: n/a
 
      7th Sep 2006
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


 
Reply With Quote
 
 
 
 
Claes Bergefall
Guest
Posts: n/a
 
      7th Sep 2006
Doesn't look like you can. I would inherit a new class from
System.Collections.ObjectModel.Collection<T> instead. That one has proteced
methods that you can override to handle insert, remove and set.

/claes


"Steve Barnett" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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
>



 
Reply With Quote
 
Steve Barnett
Guest
Posts: n/a
 
      7th Sep 2006
Much appreciated - I thought it was just me being dumb. I'll go with your
suggestion.

Thanks
Steve


"Claes Bergefall" <(E-Mail Removed)> wrote in message
news:eo$4W%(E-Mail Removed)...
> Doesn't look like you can. I would inherit a new class from
> System.Collections.ObjectModel.Collection<T> instead. That one has
> proteced methods that you can override to handle insert, remove and set.
>
> /claes
>
>
> "Steve Barnett" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>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
>>

>
>



 
Reply With Quote
 
Ben Voigt
Guest
Posts: n/a
 
      7th Sep 2006
"Steve Barnett" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Much appreciated - I thought it was just me being dumb. I'll go with your
> suggestion.
>
> Thanks
> Steve
>
>
> "Claes Bergefall" <(E-Mail Removed)> wrote in message
> news:eo$4W%(E-Mail Removed)...
>> Doesn't look like you can. I would inherit a new class from
>> System.Collections.ObjectModel.Collection<T> instead. That one has
>> proteced methods that you can override to handle insert, remove and set.
>>
>> /claes
>>


You may try BindingList<T> instead, and subscribe to the ListChanged event


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Controls collection cannot be modified ... Cal Who Microsoft ASP .NET 1 29th Dec 2009 04:35 PM
Collection was modified?! Michel Racicot Microsoft C# .NET 0 22nd Aug 2008 10:22 PM
Re: collection modified, lock ? daniel.cigic@googlemail.com Microsoft C# .NET 0 23rd May 2007 03:40 PM
collection modified, lock ? Geoffrey Microsoft C# .NET 0 23rd May 2007 01:47 PM
How do I know my collection was modified? Steve Barnett Microsoft Dot NET Framework 3 7th Sep 2006 07:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:26 AM.