DataGridView no longer resets fonts for customized cell styles
When the ambient font changes, DataGridView no longer resets default cell style fonts to match the ambient font if the cell style font has been customized.
Change description
In previous .NET versions, if the ambient font changes, DataGridView resets and overrides user-defined fonts in the DefaultCellStyle, ColumnHeadersDefaultCellStyle, and RowHeadersDefaultCellStyle properties.
Starting in .NET 5, if you configure font settings in the DefaultCellStyle, ColumnHeadersDefaultCellStyle, or RowHeadersDefaultCellStyle properties, those settings are retained even when the ambient font changes. For any of these properties that you don't customize the font, the font will change to match the ambient font settings.
Reason for change
With the change of the default font in .NET Core 3.0, the default font settings for the various cell styles also changed. This behavior is undesirable for apps that rely on custom styling in their DataGridView controls, and impeded the migration of these apps from .NET Framework to .NET 5.0.
Version introduced
.NET 5.0
Recommended action
No action is required on your part. However, if you've customized the font in the DefaultCellStyle, ColumnHeadersDefaultCellStyle, or RowHeadersDefaultCellStyle properties and want the font to match the ambient font, set DataGridViewCellStyle.Font to null
for each property.
Affected APIs
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for