问题
Application built with VS 2015, C#, Winforms, using the DateTimePicker Windows control, text is garbled after updating machines to the Windows Creators Update.
Has anyone else come across this or is there any suggested work around ?
回答1:
The June cumulative update for Windows 10 (KB 4022725) includes an updated COMCTL32.DLL that contains a fix for this issue. The file version should be 5.82.15063.413 after the update is installed.
https://social.msdn.microsoft.com/Forums/en-US/4cf03067-46c4-4962-af8c-f4b1483e88ba/date-time-picker-garbled-after-windows-10-creators-update?forum=windowsgeneraldevelopmentissues
回答2:
Enable Visual Styles in the WinForms application, before the Form containing the DateTimePicker is shown.
Application.EnableVisualStyles();
//Form1 contains the DateTimePicker component
Application.Run(new Form1());
回答3:
Do you have a High-DPI display? Even if you don't, there's a good chance the updated dpi scaling is at fault here. If so, you might be able to "fix" this simply by setting a value in dpiAware
and dpiAwareness
values of the manifest file for your project as described here:
High-DPI Scaling Improvements for Desktop Applications in the Windows 10 Creators Update
I haven't had to do this myself yet, so right now I can only point you where to look, and not to what the exact right values should be for your situation.
Even if this isn't your issue, you may want to spend a few minutes checking that your app handles well in High-DPI situation. It's also a decent excuse to get your company to buy you a nice new monitor :)
回答4:
Enabling XP Visual Styles fixed it for me.
回答5:
So Windows 10 1703 has introduced some new challenges, among them this weird refusal to display a date in the DateTimePicker control, unless you tick the "Enable XP visual style" box for the application (or do it programmatically). This tweak does fix the date-rendition issue, but now other controls, such as dropdown boxes, dropdown lists text boxes and buttons become flat and dreary. Not good. What we do need is a real fix which makes the "XP visual style" unnecessary, or is Windows Forms programming on the way out and so not interesting to support?
回答6:
I have also come across this today. My datetimepicker was rendered very randomly, but never acceptible. I have this as a sort-of workaround: My environment is VS2015, .net 3.5 and winforms My setup is Surface Pro 3 with the new docker and 2 external monitors res 2560x1440 and scaling 100%. Added app.manifest to my project as I did not have it before. Added the dpiAware to app.manifest to be System like this:
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/System</dpiAware>
</windowsSettings>
</application>
I also set the AutoScaleMode to None on my form (but got approx the same result with Inherited). The dpiAware seemed to help (but not 100% stable). This does work when running a compiled application, but does NOT work when debugging from Visual Studio. Then I only get a period (.) that is my date separation sign.
sample of datetimepicker after updating to creators update after applying workaround when running compiled exe
this can help a bit if unable to update application to .net 4.7
回答7:
So, we wound up deleting the manifest file and the control now renders correctly. What's odd is just the fact of including a new manifest file with only an assemblyIdentity tag with version and name causes this windows control to freak out. I realize that for others, deleting the manifest may not be an option, but, this has fixed our issue.
回答8:
We are receiving this exact same issue. VB.NET VS 2012 .NET 4.5. THe datetimepicker is messed up. I have also posted this on
https://connect.microsoft.com/VisualStudio/feedback/details/3129203/date-in-datetime-of-mfc-application-is-getting-cropped-in-win10-redstone2-build-15055
回答9:
I tried most of the suggestions here and in other places including manifest changes, .NET 4.7, etc. However, one additional change that was required in my setup was to increase the CalendarFont size on the control itself.
The default on my system was 7.875. Changing it to 10pt corrected the display issue (changing it to a slightly lower value improved the display but did not correct it).
Disclaimer: This has not been tested in-depth and may break other scenarios. This information is intended to assist in finding a final solution.
回答10:
Like other have suggested, had this line to your main form and it worked for me:
Application.EnableVisualStyles()
You can also uncomment the lines at the bottom in the app.manifest
. It depends of the project.
回答11:
A fix for this issue is scheduled to be included in the June cumulative update for Windows 10.
回答12:
This is a bug in the Date Time Picker control implemented in COMCTL32.DLL version 5. There should be a fix for this issue in the near future.
The Date Time Picker control implemented in COMCTL32.DLL version 6 does not appear to be affected by this issue.
来源:https://stackoverflow.com/questions/43397219/datetimepicker-garbled-after-windows-10-creators-update