From 0076b6f3da3b3cfc68afb80d8c60309125665ac6 Mon Sep 17 00:00:00 2001 From: "Leaf Shi (BEYONDSOFT CONSULTING INC)" Date: Fri, 12 Jun 2026 15:25:24 +0800 Subject: [PATCH] Fix NumericUpDown button rendering regression when visual styles are disabled --- .../UpDown/UpDownBase.UpDownButtons.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/System.Windows.Forms/System/Windows/Forms/Controls/UpDown/UpDownBase.UpDownButtons.cs b/src/System.Windows.Forms/System/Windows/Forms/Controls/UpDown/UpDownBase.UpDownButtons.cs index 35ad50fba98..57e8edf7ca4 100644 --- a/src/System.Windows.Forms/System/Windows/Forms/Controls/UpDown/UpDownBase.UpDownButtons.cs +++ b/src/System.Windows.Forms/System/Windows/Forms/Controls/UpDown/UpDownBase.UpDownButtons.cs @@ -270,7 +270,7 @@ protected override void OnPaint(PaintEventArgs e) int half_height = ClientSize.Height / 2; // Draw the up and down buttons - if (Application.IsDarkModeEnabled || !Application.RenderWithVisualStyles) + if (Application.IsDarkModeEnabled) { Graphics cachedGraphics = EnsureCachedBitmap( _parent._defaultButtonsWidth, @@ -300,7 +300,7 @@ protected override void OnPaint(PaintEventArgs e) _cachedBitmap, new Point(0, 0)); } - else + else if (Application.RenderWithVisualStyles) { VisualStyleRenderer vsr = new(_mouseOver == ButtonID.Up ? VisualStyleElement.Spin.Up.Hot @@ -341,6 +341,20 @@ protected override void OnPaint(PaintEventArgs e) new Rectangle(0, half_height, _parent._defaultButtonsWidth, half_height), HWNDInternal); } + else + { + DrawScrollButton( + e.GraphicsInternal, + new Rectangle(0, 0, _parent._defaultButtonsWidth, half_height), + ScrollButton.Up, + _pushed == ButtonID.Up ? ButtonState.Pushed : (Enabled ? ButtonState.Normal : ButtonState.Inactive)); + + DrawScrollButton( + e.GraphicsInternal, + new Rectangle(0, half_height, _parent._defaultButtonsWidth, half_height), + ScrollButton.Down, + _pushed == ButtonID.Down ? ButtonState.Pushed : (Enabled ? ButtonState.Normal : ButtonState.Inactive)); + } if (half_height != (ClientSize.Height + 1) / 2) {