From d57e4b7569103bf3a74db315f8b801b1c0a37656 Mon Sep 17 00:00:00 2001 From: Jeremy Kuhne Date: Wed, 9 Sep 2020 15:07:23 -0700 Subject: [PATCH] Change DataGridView.GridColor when set. Actually change the GridColor when set. Add a test for GridColor. Fixes #3829 --- .../src/System/Windows/Forms/DataGridView.cs | 1 + .../System/Windows/Forms/DataGridViewTests.cs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs index adf307ccbca..448b3028ef3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs @@ -2775,6 +2775,7 @@ public Color GridColor if (!value.Equals(GridPenColor)) { + GridPenColor = value; OnGridColorChanged(EventArgs.Empty); } } diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/DataGridViewTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/DataGridViewTests.cs index a1760d71811..c1e55c7f021 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/DataGridViewTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/DataGridViewTests.cs @@ -6,6 +6,7 @@ using System.ComponentModel; using Xunit; using WinForms.Common.Tests; +using System.Drawing; namespace System.Windows.Forms.Tests { @@ -2712,5 +2713,22 @@ private class SubDataGridView : DataGridView public new void OnRowHeadersWidthSizeModeChanged(DataGridViewAutoSizeModeEventArgs e) => base.OnRowHeadersWidthSizeModeChanged(e); } + + [WinFormsFact] + public void DataGridView_GridColor() + { + using var dataGrid = new DataGridView(); + + int changedCount = 0; + dataGrid.GridColorChanged += (object sender, EventArgs e) => + { + changedCount++; + }; + + dataGrid.GridColor = Color.Red; + + Assert.Equal(1, changedCount); + Assert.Equal(Color.Red, dataGrid.GridColor); + } } }