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 / March 2005

Tip: Looking for answers? Try searching our database.

Collections in designer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ViperDK \(Daniel K.\) - 08 Mar 2005 08:07 GMT
I want to edit a collection in the designer and it to be stored as well (not
binary serialized with all its version problems i got)
code should be generated with property init not with a huge constructor. any
hints which interfaces how to implement and special stuff about the
collection to use?
joeycalisay - 09 Mar 2005 10:03 GMT
binary serialized? what problems have you got?

Perhaps you have problems with typeconverters, please elaborate more on your
problem so others can help you...

Signature

Joey Calisay
http://spaces.msn.com/members/joeycalisay/

> I want to edit a collection in the designer and it to be stored as well (not
> binary serialized with all its version problems i got)
> code should be generated with property init not with a huge constructor. any
> hints which interfaces how to implement and special stuff about the
> collection to use?
Daniel K. - 10 Mar 2005 10:05 GMT
When i used it i got problems in a derived form (occasionally) that
the type was not as expected, i think some build version difference.
Anyway generating code seems a better solution since you can read it
easily in opposite to binary serialized anything.

The thing is i have a class that now works that contains kind a name
value list. its a very simple collection derived by CollectionBase and
has items with a attribute
[TypeConverter(typeof(NameIDPairConverter))]. The collection propery
in the control is marked with
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)].
Works well and code is generated that creates initialization code with
the constructor only.
 What i need more is that i want to initialize the items with its
properties and not a huge constructor and more important: i need named
objects in the collection that i can use in the code. I mean after
editing the collection i expect something in the code like:

--------------
MyItem item0 = new MyItem();
item0.Text = "asdf";
..
MyCollection = new Collection(new MyItem[] { item0, .... } );
--------------

the items are not components or controls that should be displayed on
the UI.
Would be nice to know how to create such thing or whether there is a
reference implementation. I took a look on some classes with Reflector
but they are too complex to find out what i need in an acceptable time
and seperate the code generation i want from the functionality of that
classes itself. :)

My current type converter ConvertTo looks like this:

public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType)
{
    if(destinationType == typeof(string))
    {
        NameIDPair item = (NameIDPair)value;
        return item.Name + " (ID=" + item.ID + ")";
    }

    if(destinationType == typeof(InstanceDescriptor))
    {
        NameIDPair item = (NameIDPair)value;
        ConstructorInfo ctor =
            typeof(NameIDPair).GetConstructor(new Type[] {typeof(string),
typeof(string)});
        return new InstanceDescriptor(ctor, new object[] { item.Name,
item.ID } );
    }
    return base.CanConvertTo (context, destinationType);
}

> binary serialized? what problems have you got?
>
[quoted text clipped - 8 lines]
> > hints which interfaces how to implement and special stuff about the
> > collection to use?

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.