【问题标题】:Displaying custom name instead of class type in WPF propertygrid在 WPF propertygrid 中显示自定义名称而不是类类型
【发布时间】:2015-03-12 01:06:40
【问题描述】:

查看 WPF PropertyGrid documentation 中的以下链接。 在属性网格的图像中,注意显示在 Spouse 旁边的文本是

Samples.Modules.PropertyGrid.Views.ExpandableProp

当您向客户公开 PropertyGrid 时,这看起来不太好。如何自定义我在那里显示的内容?请注意,TypeConverter 不适用于 WPF PropertyGrid。我已经试过了:)

【问题讨论】:

    标签: c# wpf propertygrid


    【解决方案1】:

    只需覆盖Person 类的ToString() 方法并返回您想要的任何内容。

    在下面的代码中,它返回名字。通过此更改,它显示Spouse 的名字而不是Samples.Modules.PropertyGrid.Views.ExpandableProp

    public override string ToString()
    {
        return FirstName;
    }
    

    【讨论】:

      猜你喜欢
      • 2017-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-21
      • 2016-10-24
      • 2012-09-18
      相关资源
      最近更新 更多