Вопрос

I saw that in order to cancel the collection editor need to set type as follows:

public class MyCollectionEditor : CollectionEditor
{
    public MyCollectionEditor(Type type)
        : base(type)
    {
    }

    public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
    {
        return UITypeEditorEditStyle.None;
    }
}

And use it like this:

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

You can find it at the following link (In answer to the question of Alan Seedhouse's):

Customized display of collection data in a PropertyGrid

My problem is that I do not define the MyCollection.cs in UI (but in class library) and therefore I can not inherit from CollectionEditor.

Is there another way to do this?

Это было полезно?

Решение

Finally it worked like this:

public class MyCollectionEditor : UITypeEditor
{ 
    public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
    {
        return UITypeEditorEditStyle.None;
    }
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top