[英]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.