CollectionEditor - Add/Remove buttons are disabled

Discussion in 'ASP .Net Building Controls' started by Dmitry Nogin, Apr 27, 2007.

  1. Dmitry Nogin

    Dmitry Nogin Guest

    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
    Dmitry Nogin, Apr 27, 2007
    #1
    1. Advertising

  2. Dmitry Nogin

    ClayB Guest

    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.
    ClayB, Apr 28, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. michael
    Replies:
    0
    Views:
    420
    michael
    May 1, 2004
  2. gozza
    Replies:
    1
    Views:
    115
    gozza
    Feb 2, 2004
  3. Custom CollectionEditor - Buttons disabled?

    , May 27, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    146
  4. CollectionEditor Remove button event?

    , Jun 28, 2005, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    228
    Ken Dopierala Jr.
    Jul 11, 2005
  5. Custom CollectionEditor - Buttons disabled?

    , May 27, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    247
Loading...

Share This Page