How do I know my collection was modified?

  • Thread starter Thread starter Steve Barnett
  • Start date Start date
S

Steve Barnett

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
 
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
 
Much appreciated - I thought it was just me being dumb. I'll go with your
suggestion.

Thanks
Steve
 
Steve Barnett said:
Much appreciated - I thought it was just me being dumb. I'll go with your
suggestion.

Thanks
Steve

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