all groups > dotnet windows forms > april 2007 >
You're in the

dotnet windows forms

group:

CollectionEditor_-_Add/Remove_buttons_are_disabled


CollectionEditor_-_Add/Remove_buttons_are_disabled Dmitry Nogin
4/27/2007 9:17:10 PM
dotnet windows forms:
Hi,

Could you please suggest me some changes?

I've got the following code, which represents the small component with =
collection property:

class Test : Component

{

private BindingList<Item> items =3D new BindingList<Item>();

=20

[Editor(typeof(CollectionEditor), typeof(UITypeEditor)),

=
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]=


public IList<Item> Items

{

get { return items; }

}

}

=20

class Item

{

private string name;

public string Name

{

get { return name; }

set { name =3D value; }

}

}

=20

Unfortunately, Add and Remove button in CollectionEditor popup dialog =
are disabled. Why? =20

I tried to inherit from Collection Editor and use the following editor:

public class ItemCollectionEditor : CollectionEditor

{

public ItemCollectionEditor(Type type)

: base(type)

{

}

=20

protected override Type CreateCollectionItemType()

{

return typeof(Item);

}

}

=20

It didn't change anything? What's wrong about this snippet?

Re: CollectionEditor - Add/Remove buttons are disabled Alex Meleta
4/27/2007 11:14:56 PM
U can use arrays against generics:

<http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=885160&SiteID=1>
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=885160&SiteID=1



WBR, Alex Meleta

Blog: http://devkids.blogspot.com



From: Dmitry Nogin [mailto:dmitrynogin@hotmail.com]
Posted At: Freitag, 27. April 2007 22:17
Posted To: microsoft.public.dotnet.framework.windowsforms
Conversation: CollectionEditor - Add/Remove buttons are disabled
Subject: CollectionEditor - Add/Remove buttons are disabled



Hi,

Could you please suggest me some changes?

I've got the following code, which represents the small component with
collection property:

class Test : Component

{

private BindingList<Item> items = new BindingList<Item>();



[Editor(typeof(CollectionEditor), typeof(UITypeEditor)),


DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
]

public IList<Item> Items

{

get { return items; }

}

}



class Item

{

private string name;

public string Name

{

get { return name; }

set { name = value; }

}

}



Unfortunately, Add and Remove button in CollectionEditor popup dialog
are disabled. Why?

I tried to inherit from Collection Editor and use the following editor:

public class ItemCollectionEditor : CollectionEditor

{

public ItemCollectionEditor(Type type)

: base(type)

{

}



protected override Type CreateCollectionItemType()

{

return typeof(Item);

}

}



It didn't change anything? What's wrong about this snippet?

Re: CollectionEditor - Add/Remove buttons are disabled ClayB
4/28/2007 1:46:48 AM
Your code worked for me when I changed

public IList<Item> Items
{
get { return items; }
}

to

public BindingList<Item> Items
{
get { return items; }
}

Maybe the CollectionEditor knows it can add and remove from
BindingList<> depending upon AllowNew and AllowRemove settings, but it
does not know how to do this for IList<>.

================
Clay Burch
Syncfusion, Inc.
AddThis Social Bookmark Button