Question

I'm using the Winforms PropertyGrid; the target of the SelectedObject includes a property of type Image. Everything is fine, except that with all items the same height, the image is too small to see properly. I'd like to have some control over the height of grid items such that the image can be displayed a bit larger. One other detail is that the SelectedObject of one PropertyGrid control may be assigned an object of any of a variety of different classes (which may or may not have image properties), so I'm hoping the height can be driven by data in the instance of the SelectedObject itself, rather than making it a static behavior of the control, although I'd settle for a custom attribute of the image property to make the item height at least class-specific if it can't be instance-specific.

How can I do this? Custom attribute? PropertyGrid event? Something else?

Was it helpful?

Solution

As Simon commented on your question, this is not possible to have a custom height for a GridItem.

You have 2 solutions to be able to show an image with a reasonable size:

  1. You can code your own UITypeEditor. That way, the user would just click the down arrow and see a nicely sized image in the dropdown box.

  2. Sorry for the plug but I think it directly answers your question: only 3rd party PropertyGrids may allow you to get variable size rows in the grid. Smart PropertyGrid.Net is one of them. You set a HeightMultiplier to the row so that it expands on let's say 4 rows. Then you code your own Look class that handles the drawing of the image the way you want in this space.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top