0

我的默认属性窗口如下所示: 在此处输入图像描述

有可能以某种方式改变这种观点吗?

例如,我想显示我的 Template.Name 属性值和 Template.Description,而不是 [array index] 和命名空间。

有没有可能做到这一点?

4

1 回答 1

1

我认为,尝试通过继承类CollectionConverter和覆盖方法ConvertTo。然后将新的自定义转换器类作为属性分配给TypeConverter属性。

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";
    }
}

在物业上:

[TypeConverter(typeof(TemplateArrayConverter))]
public OutlookAddIn_MailHelper.Template[] Templates { get; set;}
于 2015-02-12T22:36:47.613 回答