I have a control which hosts a NumericUpDown
in a ToolStripControlHost
and exposes the NumericUpDown
's properties. Functionally, that's fine, but when it's placed on a ToolStrip
it doesn't fit visually with the other ToolStripItem
s.
I'd like to use the ToolStrip
's existing ToolStripRenderer
to draw the control in a manner similar to the ToolStripComboBox
es that are also on the control. I'm not interested in creating a custom ToolStripRenderer
to do that, as I want others who use the control to be able to use it with whichever renderer they choose.
I've tried overriding OnPaint
and OnPaintBackground
in the hosting control class, and in the hosted control class, and using the renderer's drawing methods, but all I can achieve is to have an unpainted region around the edges; the spin buttons are still drawn with the system theme.
How do I paint a hosted NumericUpDown
using the existing ToolStripRenderer
?
-
The NumericUpDown class is really just a wrapper around the common control class that exists as part of GDI. The underlying common control will draw itself in one of two ways depending on if visual styles are enabled for the application. To override the drawing you will need to perform all the drawing yourself. You cannot tell the control you want to only override the buttons or the border.
Performing all the drawing yourself is much harder than it sounds. Sorry I cannot offer an easy solution but I do not think there is an easy solution.
Simon : I want to do all the drawing myself, but I want to use the ToolStripRenderer's methods to do it.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.