views:

46

answers:

1

I'm using a WinForms property grid to display the properties of an object. However, most of the properties are read only and thus show up as grey rather then black. Is there a way to customize the colors that are used? I'd like the disabled properties to be a bit easier to read.

BTW: I think the answer to this question might be related to what I'm trying to do. But I'm not sure exactly how I can access ControlPaint.DrawStringDisabled.

A: 

Unfortunately, there's no built in way to change the colour. As with a lot of the standard .NET controls, they're merely wrapped versions of their COM equivalents.

What this means in practice is that a lot, if not all of the painting is done by the COM component, so if you try overriding the .NET OnPaint method and calling ControlPaint.DrawStringDisabled or any other painting code, it's more than likely going to have an undesired effect, or no effect what-so-ever.

Your options are:

  1. Build a custom control from scratch (probably the easiest)
  2. Override WndProc and try to intercept paint messages (not guaranteed to work)
  3. Attempt to override OnPaint and do your painting on top (not guaranteed to work)

Sorry that's probably not the answer you wanted, but I can't think of an easier method. I know from bitter experience that this sort of thing can be hard to modify.

nukefusion