Can we change the text / background color of an individual object in the PropertyGrid

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

  • If there is an easier way?
  • If I use a dedicated editor, then how do I change the editor for built-in types like bool, int, etc.

thanks

+2


a source to share


1 answer


No. The class that determines how the item is created is PropertyGridView. The original code is interesting, it almost did it:

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

      



No, it looks like they decided at the last minute not to allow method overrides. The PropertyGridView class has also been marked as internal. Replacing all this code (there is a lot) is not a realistic option.

Creating your own UITypeEditor for built-in types is only possible by applying the [Editor] attribute to the properties of the class you want to edit. This is not a general solution. Consider creating your own shape to make the object editable.

+6


a source







All Articles