From 7af33149aae6c8537941293681d9033cbf616dda Mon Sep 17 00:00:00 2001 From: "Leaf Shi (BEYONDSOFT CONSULTING INC)" Date: Thu, 7 Aug 2025 20:17:07 -0700 Subject: [PATCH 1/2] Add judgement "IsDarkModeEnabled" for SelectionForeColor of DataGridView --- .../Windows/Forms/Controls/DataGridView/DataGridView.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridView.cs b/src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridView.cs index 75a47694c6d..6b8fdc70f99 100644 --- a/src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridView.cs +++ b/src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridView.cs @@ -2061,7 +2061,9 @@ private DataGridViewCellStyle DefaultDefaultCellStyle BackColor = s_defaultBackColor, ForeColor = SystemInformation.HighContrast ? DefaultForeBrush.Color : base.ForeColor, SelectionBackColor = DefaultSelectionBackBrush.Color, - SelectionForeColor = DefaultSelectionForeBrush.Color, +#pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. + SelectionForeColor = Application.IsDarkModeEnabled ? SystemColors.ControlText : DefaultSelectionForeBrush.Color, +#pragma warning disable WFO5001 Font = base.Font, AlignmentInternal = DataGridViewContentAlignment.MiddleLeft, WrapModeInternal = DataGridViewTriState.False From 48b13a4309190d86b15e99b6e5eb66d986cd6037 Mon Sep 17 00:00:00 2001 From: Leaf Shi <132890443+LeafShi1@users.noreply.github.com> Date: Mon, 18 Aug 2025 20:27:50 -0700 Subject: [PATCH 2/2] Update src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridView.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../System/Windows/Forms/Controls/DataGridView/DataGridView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridView.cs b/src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridView.cs index 6b8fdc70f99..1212f20b5b4 100644 --- a/src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridView.cs +++ b/src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridView.cs @@ -2063,7 +2063,7 @@ private DataGridViewCellStyle DefaultDefaultCellStyle SelectionBackColor = DefaultSelectionBackBrush.Color, #pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. SelectionForeColor = Application.IsDarkModeEnabled ? SystemColors.ControlText : DefaultSelectionForeBrush.Color, -#pragma warning disable WFO5001 +#pragma warning restore WFO5001 Font = base.Font, AlignmentInternal = DataGridViewContentAlignment.MiddleLeft, WrapModeInternal = DataGridViewTriState.False