From 5e0db94a8129044e8a6e46f2aeaf0305f5a13b6b Mon Sep 17 00:00:00 2001 From: "Simon Zhao (BEYONDSOFT CONSULTING INC)" Date: Fri, 29 May 2026 15:02:38 +0800 Subject: [PATCH] Fix ComboBox dark mode theme on first TabPage --- .../Forms/Controls/TabControl/TabControl.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/System.Windows.Forms/System/Windows/Forms/Controls/TabControl/TabControl.cs b/src/System.Windows.Forms/System/Windows/Forms/Controls/TabControl/TabControl.cs index 73f78d1df17..9c063187ad4 100644 --- a/src/System.Windows.Forms/System/Windows/Forms/Controls/TabControl/TabControl.cs +++ b/src/System.Windows.Forms/System/Windows/Forms/Controls/TabControl/TabControl.cs @@ -1787,9 +1787,19 @@ private bool ShouldSerializeItemSize() return !_padding.Equals(s_defaultPaddingPoint); } - private BOOL StyleChildren(HWND handle) => - PInvoke.SetWindowTheme(handle, $"{DarkModeIdentifier}_{ExplorerThemeIdentifier}", null) - .Succeeded; + private BOOL StyleChildren(HWND handle) + { + // Only apply theme to direct children (TabPages), not to controls within TabPages. + // Controls like ComboBox need their own specific dark mode themes. + HWND parent = PInvoke.GetParent(handle); + if (parent == HWND) + { + return PInvoke.SetWindowTheme(handle, $"{DarkModeIdentifier}_{ExplorerThemeIdentifier}", null) + .Succeeded; + } + + return true; + } /// /// Returns a string representation for this control.