|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
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 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 Show quote "Steve Barnett" <non***@nodomain.com> wrote in message news:eYHsJzo0GHA.4796@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 > Much appreciated - I thought it was just me being dumb. I'll go with your
suggestion. Thanks Steve Show quote "Claes Bergefall" <louplou@nospam.nospam> wrote in message news:eo$4W%23o0GHA.3476@TK2MSFTNGP04.phx.gbl... > 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" <non***@nodomain.com> wrote in message > news:eYHsJzo0GHA.4796@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 >> > >
Show quote
"Steve Barnett" <non***@nodomain.com> wrote in message You may try BindingList<T> instead, and subscribe to the ListChanged eventnews:O8qn0cp0GHA.2072@TK2MSFTNGP06.phx.gbl... > Much appreciated - I thought it was just me being dumb. I'll go with your > suggestion. > > Thanks > Steve > > > "Claes Bergefall" <louplou@nospam.nospam> wrote in message > news:eo$4W%23o0GHA.3476@TK2MSFTNGP04.phx.gbl... >> 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 >> |
|||||||||||||||||||||||