tags:

views:

165

answers:

2

I want to draw spinner controls, such as those found on a NumericUpDown, on a custom component. If I want to draw a drop-down button, I can use ComboBoxRenderer. Is there an equivalent of ComboBoxRenderer for NumericUpDown?

A: 

I do not think a ComboBoxRenderer exists in the Windows Forms namespace. You need to directly draw the UpDown control arrows (spin buttons) using interop and the Theme API. I don't have a complete sample for you, but you'll need

[DllImport("uxtheme.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
public static extern IntPtr OpenThemeData(IntPtr hWnd, String classList);

[DllImport("uxtheme", ExactSpelling = true)]
public extern static Int32 DrawThemeBackground(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pRect, IntPtr pClipRect);

[DllImport("uxtheme.dll", ExactSpelling = true)]
public extern static Int32 CloseThemeData(IntPtr hTheme);

and you can find the required parts and states in this page (look for the SPIN style class and its associated parts and states).

Alan
A: 

Turns out there is. See the VisualStyleElement.Spin class.

Simon