collection property and refresh control

A

--== Alain ==--

Hi,

I have a control which has a collection property.
when an item of the collection property will be added, removed, and so
on, i would like to refresh the control itself.

Usually for that i use eventhandler in the set method of the property.
But as the collection property has only a get method, i'm not able to do
it so.

Therefore, i would like to know how can i do to refresh the parent
control (container) of my collection property when a collection item is
changed ?

thanks a lot,

Al.
 
G

Guest

I have a control which has a collection property.
when an item of the collection property will be added, removed, and so
on, i would like to refresh the control itself.

Usually for that i use eventhandler in the set method of the property.
But as the collection property has only a get method, i'm not able to do
it so.

Therefore, i would like to know how can i do to refresh the parent
control (container) of my collection property when a collection item is
changed ?

If you're using .NET 2.0, take a look at the BindingSource object. If your
controls are bound to a bindingsource object, they'll refresh
automatically.
 
R

RobinS

You have posted this to at least the following newsgroups.

microsoft.public.dotnet.framework.windowsforms.controls
microsoft.public.dotnet.general
microsoft.public.dotnet.languages.csharp
microsoft.public.dotnet.languages.vb

In the future, if you feel a need to do that, please put all the groups in
the header post them all at once. That way, if someone in one newsgroup
provides an answer, it shows up in all of the groups you posted it in, and
the others know they can spend their time helping someone else.

Thanks,
Robin S.
 
D

dippykdog

Therefore, i would like to know how can i do to refresh the parent
If you're using .NET 2.0, take a look at the BindingSource object. If your
controls are bound to a bindingsource object, they'll refresh
automatically.

If you're not using 2.0, you can mimic binding by creating an update
event on the item (raise this event whenever an item property is
changed). Handle this event in the collection by raising another event
there (e.g., ItemUpdated), and handle that event in the control. You
could also have other events to distinguish among what's going on in
the collection:
ItemUpdated - when an item raises its update event
ItemAdded - raised by collection when item is added
ItemRemoved -...
etc.
The control (or whatever is using the collection) can then react with
precision to different activities in the collection.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top