dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.35k stars 964 forks source link

[Dark Mode] Some rows/columns and ColumnHeader/RowHeader in the DataGridView control have incorrect colors #11893

Open Philip-Wang01 opened 3 weeks ago

Philip-Wang01 commented 3 weeks ago

.NET version

.NET SDK 9.0.100-rc.1.24415.1 + build private dll form winforms repo release/9.0 branch

Did it work in .NET Framework?

No

Did it work in any of the earlier releases of .NET Core or .NET 5+?

This is a new feature Dark Mode: https://github.com/dotnet/winforms/pull/11857

Issue description

Button and combobox types rows/columns and ColumnHeader/RowHeader in the DataGridView control have incorrect colors image

Steps to reproduce

  1. Create a WinForms .NET Core application with DataGridView control.
  2. Enable DarkMode by Application.SetColorMode(SystemColorMode.Dark) in program.cs file.
  3. Add different types of columns to the DataGridView, such as button, checkbox and combobox.
  4. Run the application.
  5. Observe the result.
memoarfaa commented 3 weeks ago

@Philip-Wang01 Temporary solution is set "FlatStyle" to "FlatStyle.Flat"

I notice that Any normal Button has property FlatStyle set to "FlatStyle.Standard" or has "UseVisualStyleBackColor" set to "true" will use light Color Mode

So any drawing related to Visual style will be in Light Mode like (ButtonRenderer , VisualStyleRenderer, UseVisualStyleBackColor, FlatStyle.Standard)

The WinForms team has no intention of supporting Dark Mode Visual style in .NET SDK 9 according to @KlausLoeffelmann statements here he say it will be completed in .NET SDK 10.

https://github.com/dotnet/winforms/pull/10985#discussion_r1650160238

You can see the difference between Buttons in this images on use Light ButtonRenderer and another use Dark ButtonRenderer

Light Mode ButtonRenderer

2024-08-16_11-59-20

Dark Mode ButtonRenderer

2024-08-16_12-18-11

KlausLoeffelmann commented 3 weeks ago

The WinForms team has no intention of supporting Dark Mode Visual style in .NET SDK 9 .

Well, to be fair, we had every intention possible. And we all know of course, that the VisualStylesMode features, although technically a separate feature, is very closely related to the dark mode in a lot of areas - this just being one of them. But at one point we/I also need to accept, that Visual Styles might have introduced incompatibilities, where we cannot with good conscience accept something that we passionately want to let jeopardize the stability of the system. We're not saying that that would have happened. But we were "just" not sufficiently sure. And even this being an Experimental feature doesn't mean, it does not need to meet a min bar for stability and safety AND we are sure about that it has all that. Did it have it? Yeah, very likely. Were we 100% sure? No. That's why it was the right decision to slip it into 10. And we always knew, with the existing workload, that this could happen, and we reserved the right to slip it even up to the very end: We aimed and work hard for making it happen as an Experimental feature with the primary goal to collect feedback - NOT to use it in production until the very last minute. We could have made that call in May and say, no, it's too close, other work items with higher priority just made it necessary to postpone. And we definitely WOULD have made that call earlier, had that feature not been conceptualized as an experimental feature to begin with.

So, Dark Mode made it, Visual Styles did not.

It was the right call. @JeremyKuhne, @merriemcgaw.