Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / January 2005

Tip: Looking for answers? Try searching our database.

Collections Added Twice at Design Time

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Adam Dockter - 10 Jan 2005 23:01 GMT
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.
joeycalisay - 11 Jan 2005 01:22 GMT
> 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.

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...
Adam Dockter - 11 Jan 2005 21:44 GMT
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.

> > For example:
> > I add OBJ1 - this works fine.
[quoted text clipped - 4 lines]
> obj2, the behavior is expected, same with the third case.  Anyways, it is
> always better to see a snippet than commenting using induction...

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.