all groups > dotnet windows forms designtime > january 2005 >
You're in the

dotnet windows forms designtime

group:

Collections Added Twice at Design Time


Collections Added Twice at Design Time Adam Dockter
1/10/2005 4:01:11 PM
dotnet windows forms designtime:
I have implemented a simple collection of objects using IList and put the
following attributes on the collection property.

[Category("Behavior")
,Browsable(true)
,DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
,EditorAttribute(typeof(CollectionEditor),typeof(UITypeEditor))]

Everything compiles fine but if I add objects at design time it trys to add
all the objects multiple times.
For example:
I add OBJ1 - this works fine.
When I add OBJ2 - it first adds OBJ1 and then adds OBJ2
When I add OBJ3 - first it adds OBJ1 then OBJ2 the OBJ3.

It doesn't serialize like this but it causes the display to do this. Has
anyone else ever ran into this. It happens to me on all my collections. I
am sure I am doing something wrong I just don't know what. If you would
like a copy of the source let me know. It is too much to post in this
message.

Any help is appreciated.
-Adam dR.


Re: Collections Added Twice at Design Time joeycalisay
1/11/2005 9:22:04 AM
[quoted text, click to view]

I don't get it, if you did not remove obj1 from the collection before adding
obj2, the behavior is expected, same with the third case. Anyways, it is
always better to see a snippet than commenting using induction...

Re: Collections Added Twice at Design Time Adam Dockter
1/11/2005 2:44:39 PM
Sorry for the vague question:
I did end up figuring out the solution how ever. What I didn't know was
that the designer calls Clear on you collection each time you add an new
object and then adds all the objects again. My problem was occuring because
I did not properly implement Clear and then It kept adding duplicates to my
collection.

Thanks for the help.


[quoted text, click to view]

AddThis Social Bookmark Button