简体   繁体   English

您如何自定义集合编辑器的标题?

[英]How do you customize the header of the Collection Editor?

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. 然后,我使用PropertyGrid通过标准的集合编辑器来编辑此列表的对象。 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". 例如,我想将“ MyItemClass Collection Editor”替换为“ My Favorite Item Collection Editor”。

How can I change the header of Collection Editor? 如何更改集合编辑器的标题?

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: CollectionEditor类继承一个自定义类,重写CreateCollectionForm方法并修改基类返回的CollectionForm实例的Text属性:

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

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

        collectionForm.Text = "My title";

        return collectionForm;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何自定义PropertyGrid对象的集合编辑器中的描述? - How do you customize the descriptions in the Collection Editor of the PropertyGrid object? 如何在PropertyGrid自定义集合编辑器中的“添加”按钮下拉列表中自定义名称 - How to customize names in “Add” button dropdown in the PropertyGrid custom collection editor 如何创建自定义集合编辑器表单以与属性网格一起使用? - How do you create a custom collection editor form for use with the property grid? 如何自定义DataGrid标头? - How to customize DataGrid header? 你如何“适应”一个集合的集体成员? - How do you 'adapt' a class member that is a collection? 默认的ControlTemplates如何让您不使用TemplateBinding进行自定义? - How do the default ControlTemplates let you customize without TemplateBinding? 如何使用 AutoFixture 自定义集合 - How to use AutoFixture to customize a collection 如果您在View中更改集合的值,如何通知ViewModel - how do you Notify the ViewModel if you change values of a collection in the View 如何自定义报告中的标题? - How to customize the header in my report? 如何在Gtk Sharp中创建语法高亮文本编辑器? - How do you make a Syntax Highlight Text Editor in Gtk Sharp?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM