Question

I have a owner drawn control where I need to draw the expand box ("plus/minus") of a treeview. With visual styles turned on it is easy, just create a renderer for the appropriate VisualStyleElement:

VisualStyleElement element = VisualStyleElement.TreeView.Glyph.Opened
VisualStyleRenderer renderer = new VisualStyleRenderer( element );
Size size = renderer.GetPartSize( graphics, ThemeSizeType.True );
...
renderer.DrawBackground( graphics, someRect );

Is it possible to achieve a similar effect when visual styles are off? I know there is a ControlPaint class which can draw entire controls, but how do I draw (and get the size of) just a part of the TreeView control?

Was it helpful?

Solution

Without VisualStyles, I think the plus minus controls are just DrawRectangle and DrawLine method calls.

The Rectangle part looks like it uses the SystemColors.Control color, and the Plus/Minus part looks like SystemColors.ControlText (or black).

enter image description here

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