How do you customize the header of the Collection Editor?

996 views Asked by At

I have a class that contains several public properties. I made a List containing instances of this class. Then I use PropertyGrid to edit objects of this List with a standard Collection Editor. I found out how to customize names of fields, but I still can't change the header of Collection Editor.

For example I want to replace "MyItemClass Collection Editor" with "My Favourite Item Collection Editor".

How can I change the header of Collection Editor?

1

There are 1 answers

0
Oliver On BEST ANSWER

Inherit a custom class from CollectionEditor class, override the CreateCollectionForm method and modify the Text property of the CollectionForm instance returned by the base class:

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

    protected override CollectionForm CreateCollectionForm()
    {
        CollectionForm collectionForm = base.CreateCollectionForm();

        collectionForm.Text = "My title";

        return collectionForm;
    }
}