C# 在PropertyGrid的集合编辑器中更改类型名称
我在ManageConfig类中有一个属性C# 在PropertyGrid的集合编辑器中更改类型名称,c#,.net,winforms,propertygrid,C#,.net,Winforms,Propertygrid,我在ManageConfig类中有一个属性 public class ManageConfig { [Category("Config")] [Description("Read and write specific")] [DisplayName("Camera Settings")] public List<Config> Configuration { get; set; } } public
public class ManageConfig
{
[Category("Config")]
[Description("Read and write specific")]
[DisplayName("Camera Settings")]
public List<Config> Configuration
{
get;
set;
}
}
public class Config
{
public string ConfigName { get; set; }
public string ConfigValue { get; set; }
}
public类ManageConfig
{
[类别(“配置”)]
[说明(“读写特定”)]
[显示名称(“摄像机设置”)]
公共列表配置
{
得到;
设置
}
}
公共类配置
{
公共字符串ConfigName{get;set;}
公共字符串配置值{get;set;}
}
当我在propertygrid I get窗口中打开集合时,我可以在其中添加或删除项,项名称是类名Config,我希望在更改每个项的ConfigName属性时更改项名称
感谢您可以重写
Config
类的ToString
方法,以指定集合编辑器在项目列表的左面板中显示的内容:
public override string ToString()
{
if(!string.IsNullOrEmpty(ConfigName))
return ConfigName;
return base.ToString();
}