Skip to content

Commit 1185aac

Browse files
authored
Change DataGridView.GridColor when set. (#3869)
Actually change the GridColor when set. Add a test for GridColor. Fixes #3829
1 parent b25cb49 commit 1185aac

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2775,6 +2775,7 @@ public Color GridColor
27752775

27762776
if (!value.Equals(GridPenColor))
27772777
{
2778+
GridPenColor = value;
27782779
OnGridColorChanged(EventArgs.Empty);
27792780
}
27802781
}

src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/DataGridViewTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.ComponentModel;
77
using Xunit;
88
using WinForms.Common.Tests;
9+
using System.Drawing;
910

1011
namespace System.Windows.Forms.Tests
1112
{
@@ -2712,5 +2713,22 @@ private class SubDataGridView : DataGridView
27122713

27132714
public new void OnRowHeadersWidthSizeModeChanged(DataGridViewAutoSizeModeEventArgs e) => base.OnRowHeadersWidthSizeModeChanged(e);
27142715
}
2716+
2717+
[WinFormsFact]
2718+
public void DataGridView_GridColor()
2719+
{
2720+
using var dataGrid = new DataGridView();
2721+
2722+
int changedCount = 0;
2723+
dataGrid.GridColorChanged += (object sender, EventArgs e) =>
2724+
{
2725+
changedCount++;
2726+
};
2727+
2728+
dataGrid.GridColor = Color.Red;
2729+
2730+
Assert.Equal(1, changedCount);
2731+
Assert.Equal(Color.Red, dataGrid.GridColor);
2732+
}
27152733
}
27162734
}

0 commit comments

Comments
 (0)