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

Tip: Looking for answers? Try searching our database.

Custom Object Collection Editors

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ShiveleyTom - 16 Oct 2006 03:01 GMT
I am attempting to make any Array or Collection properties I create in my
UserControls or Components editable through the PropertyGrid during design
time.
First, how do I make the results of adding objects through the editor to be
saved into the member storing the Array or Collection?
Also, I would like to know how to attach Arrays of objects similar to how
Columns are linked to Tables or DataGrid objects through the collection
editor.
I have been able to successfully make the properties Browsable by the
PropertyGrid, but now having trouble making the next steps work properly.

Thank you.
Bernd S - 18 Oct 2006 14:05 GMT
Here is an example from my code:

If your collection is named "MyCollection":

- add an EditorAttribute to your collection's constructor:

[Editor(typeof(MyCollectionEditor),
typeof(System.Drawing.Design.UITypeEditor))]
public class MyCollection : CollectionBase

- implement the CollectionEditor, where you can override CreateNewItemTypes:
public class ControlSpecCollectionEditor : CollectionEditor
{
protected override Type[] CreateNewItemTypes()
{
   return new Type[3] { typeof( ElemA), typeof( ElemB), typeof( ElemC) };
}
}

- mark the collection property as DesignerSerializationVisibility.Content
[DesignerSerializationVisibility( DesignerSerializationVisibility.Content )]
public MyCollection MyElements
{
get
{
    return ...
}
}

Hope that helps.

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.