[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

CollectionEditor - Add/Remove buttons are disabled

Dmitry Nogin

4/27/2007 6:17:00 PM

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?

-- thanks


1 Answer

ClayB

4/28/2007 8:47:00 AM

0

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.