0

I have default properties window looks like next: enter image description here

Is it possible to change somehow this view?

For example I want to show my Template.Name property value and Template.Description instead [array index] and namespase.

Any possibilities to do that?

Ksice
  • 3,277
  • 9
  • 43
  • 67
  • 1
    You can override ToString: the PropertyGrid is using that method to obtain the text to be displayed as each item's value. – Rubidium 37 Feb 02 '15 at 15:56
  • 1
    Something like this? http://www.codeproject.com/Articles/4448/Customized-display-of-collection-data-in-a-Propert – Panu Oksala Feb 02 '15 at 18:12

1 Answers1

1

I think, try by inherit class CollectionConverter and override method ConvertTo. And then assign the new custom converter class as a attribute: TypeConverter to the property.

internal class TemplateArrayConverter : CollectionConverter
{
    public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destType)
    {
        if (destType == typeof(String) && value is OutlookAddIn_MailHelper.Template[])
        {
            OutlookAddIn_MailHelper.Template[] templates = (OutlookAddIn_MailHelper.Template[])value;
            if (templates.Length > 0)
            {
                return String.Format("Total Template: {0}", templates.Length);
            }
        }

        return "None";
    }
}

On the property:

[TypeConverter(typeof(TemplateArrayConverter))]
public OutlookAddIn_MailHelper.Template[] Templates { get; set;}
S_R
  • 157
  • 1
  • 4