我们可以改变在PropertyGrid中的某个属性的文本/背景颜色 [英] Can we change the text/background color of an individual property in PropertyGrid

查看:325
本文介绍了我们可以改变在PropertyGrid中的某个属性的文本/背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.NET的PropertyGrid控制,显示一些类的属性。我想改变颜色或字体或背景颜色(也没关系只是它们看起来不同于其他显示的属性)的一些属性。我可以编写自定义编辑器做的,但我不知道

I have a .NET PropertyGrid control which displays properties of some class. I want to change the color or font or background color(it doesn't matter just that they look different from the other displayed properties) of some property. I can do with writing custom editor but I was wondering

  1. 如果一个更简单的方法是否存在?
  2. 如果我用自定义编辑器那么如何更改内置的类型,如BOOL,INT等编辑器。

感谢

推荐答案

没有能够做到。类,它确定如何将项目绘制的PropertyGridView。该人士$ ​​C $ c是有趣的,它几乎做到:

No can do. The class that determines how an item is drawn is PropertyGridView. The source code is interesting, it almost made it:

    private /*protected virtual*/ PropertyGridView CreateGridView(IServiceProvider sp) {
        return new PropertyGridView(sp, this);
    }

不,看起来像在他们决定不制作方法重写的最后一分钟。该PropertyGridView类也被标记为内部。更换所有这些code(存在的很多的它)不是一个现实的选择。

Nope, looks like at the last minute they decided against making the method overridable. The PropertyGridView class was also marked internal. Replacing all this code (there is a lot of it) is not a realistic option.

创建自己的UITypeEditor的内置类型只能通过应用属性到你想要编辑的类的属性。这不是一个通用的解决方案。考虑创建自己的形式,使对象编辑代替。

Creating your own UITypeEditor for built-in types is only possible by applying the attribute to the properties in the class you want to edit. That's not a general solution. Consider creating your own form to make the object editable instead.

这篇关于我们可以改变在PropertyGrid中的某个属性的文本/背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆