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 / June 2006

Tip: Looking for answers? Try searching our database.

CollectionEditor - validation that only allows unique items in the collection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sergiy - 08 Jun 2006 06:20 GMT
Hi all,
I have a custom UI control with a collection property that I can edit with a
CollectionEditor at design-time.

To achieve this I've used the Editor attribute (from System.ComponentModel)
on the collection property and created a class that derives from
CollectionEditor and overrides some methods. To keep it simple the type of
items the collection contains are objects with a single string property
called Name.

I'm looking for a way to validate new added items in CollectionEditor to
make sure that they all have a unique Name in the collection.

So far I've tried overriding CreateInstance() and SetItems() methods, but
haven't been able to enforce unique names.

Any ideas?

Thanks in advance.
Dave Sexton - 21 Jun 2006 23:37 GMT
Hi Sergiy,

Override the CreateControlsInstance method and return a custom
Control.ControlCollection-derived Type.  You can override the Add and
AddRange method to check if the name is unique before allowing the Control
to be added to the collection.  You can throw and error if the name is not
unique.  The error thrown by your custom Control.ControlCollection-derived
Type will be caught by VS.NET and displayed to the user as a standard dialog
error.

HTH

> Hi all,
> I have a custom UI control with a collection property that I can edit with
[quoted text clipped - 15 lines]
>
> Thanks in advance.

Rate this thread:







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.