Closed kirsan31 closed 4 years ago
Is this a blocker? If so, what is the impact? We need to have a good justification for the servicing team.
@RussKie
Is this a blocker? If so, what is the impact? We need to have a good justification for the servicing team.
Yes of course! Grid control is totally broken - you can't customize fonts!!! In migration (to core) terms: every grid with custom fonts (in our apps it's all of them - 100%) are broken.
Confirmed - setting the form font breaks dataGridView fonts... Due to the change of the default font in core, we had to explicitly set the font in each form during migration.
Hi @RussKie . I have reproduced this issue on .NET Framework (4.7.1 and 4.8) and .NET Core (3.1 and 5.0). Issue is reproduced when Form's file contains next code:
this.Font = new System.Drawing.Font(...)
CTI team also reproduced it on .NET Framework project (https://github.com/dotnet/winforms/issues/3033#issuecomment-610882306).
I asked CTI team verify it and confirm. If this is confirmed, then we must remove the regression label
If this is confirmed, then we must remove the regression label
I'd still consider fixing this important (and arguably a regression), since porting applications to .NET Core currently requires setting the font and thus triggering the bug, while on Desktop you could get away with not setting it.
Alternatively implement #3001 then fixing this issue is (probably?) not so important anymore.
@SergeySmirnov-Akvelon
Form's file contains next code:
this.Font = new System.Drawing.Font(...)
This is not exactly the truth. Strictly speaking the problem appear when the form Font != DefaultFont
.
So this line
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
will not break .net Framework version. And this:
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
will not break .net core version.
@weltkante
Alternatively implement #3001 then fixing this issue is (probably?) not so important anymore.
I am afraid that this will not help :( ...
Also, during testing, I found that changing the form's Font - will delete ColumnHeadersDefaultCellStyle and RowHeadersDefaultCellStyle
Please raise in the designer repo. /cc: @merriemcgaw
@RussKie I have one more original designer bug for dataGridView π Can I do something or wait for new designer?
@kirsan31 sorry, that comment was meant for @SergeySmirnov-Akvelon, I thought he posted that. I totally understand the frustration, I too as a user of Windows Forms frustrated by deficiencies in the code base and the lack of 100% functioning designer. The team is working hard to deliver the best possible experience, but it is a fundamentally very laborious and complex task, and it takes time. Unfortunately there is only so many hours in a day, and nine pregnant women won't deliver a baby in one month...
I'd still consider fixing this important (and arguably a regression)
Since this behaviour exists in .NET Framework, this is not a regression. Obviously it manifests itself due to https://github.com/dotnet/winforms/pull/656, which set the new default font. Sadly no-one anticipated such a far reaching impact of that change. We will certainly fix the issue, however since it is not a regression, the priority and the time frame are TBD.
Also, during testing, I found that changing the form's Font - will delete ColumnHeadersDefaultCellStyle and RowHeadersDefaultCellStyle
@RussKie, @kirsan31 , the https://github.com/dotnet/winforms-designer/issues/2153 is filed to address the this issue. /cc: @merriemcgaw
My understanding align with what @kirsan31 said above (appear when the form Font != DefaultFont). Default winforms applications do not write the 'Font' statement in to the code file. This is going to be a visible issue in core for the applications that set the default(classic framework) font explicitly in the code. Overriding DGV font ( i think this is not limited to DGV only) with Forms font was original implementation and any generic change here would need be designed by keeping other controls in mind.
@kirsan31 , I want to understand little bit more on your broken application scenario. If you remove the explicit default Font statement from the Forms initialization code, my understanding is, you should be able preserve DGV custom fonts. Is this something you already tried and did not work?
FYI - as this is winforms runtime issue, I will have to close the issue opened in the designer repo. We will track it in this repo.
@dreddy-work
I want to understand little bit more on your broken application scenario. If you remove the explicit default Font statement from the Forms initialization code, my understanding is, you should be able preserve DGV custom fonts. Is this something you already tried and did not work?
Yes, your understanding is right. BUT, due to the change of the default font in core, to achieve form look like it was designed, we need to set forms' font any way :( And even if you will do it in runtime (when form already visible), it will break all dataGridView fonts.
But for us, the problem magically solved (for now) because all our users switched to hi dpi monitor's :) And .net core app look with default system font (forms and controls are sized about 27% larger) is good with 100% DPI :) In .net framework version they use 125% DPI.
FYI - as this is winforms runtime issue, I will have to close the issue opened in the designer repo. We will track it in this repo.
Subj defiantly is winforms runtime issue, but issue opened in the designer repo must be Also, during testing, I found that changing the form's Font - will delete ColumnHeadersDefaultCellStyle and RowHeadersDefaultCellStyle (see bottom of linked message). And it's defiantly designer problem.
Also, i have no answer for this question :
I have one more original designer bug for dataGridView smirk Can I do something or wait for new designer?
I have one more original designer bug for dataGridView π Can I do something or wait for new designer?
Sorry, I missed it. The best way to report the designer bugs via the VS Feedback - it collects necessary telemetry for the team to triage. We look at all reports, and some bugs may have workarounds, while others have to be prioritised for a fix.
@RussKie
The best way to report the designer bugs via the VS Feedback - it collects necessary telemetry for the team to triage. We look at all reports, and some bugs may have workarounds, while others have to be prioritised for a fix.
Thank your, I will wait for dataGridView designer in core and check it there...
Use this:
Whilst it may not be perfect it helps routing issues to responsible teams. There are dozens of teams and hundreds of engineers working on VS and .NET world-wide.
It is almost impossible for a issue opened there to reach its destination :(
I don't believe it is (entirely) true. Issues with Windows Forms and the Designer are routed to our team.
Issues with Windows Forms and the Designer are routed to our team.
You have convinced me - I will try (just out of love for WinForms :))) )...
Once you'll have raised it feel free to email or twitter DM a link to me.
Sometimes there are routing mistakes, but if you are able to give us the link to the issue created, we can jump on it and make sure it ends up on our radar right away.
@RussKie @merriemcgaw Done: https://developercommunity.visualstudio.com/content/problem/1143911/winforms-datagridview-styles-designer-bugs.html Sorry for delay, had many troubles recently due to 16.7 breaking designer...
@kirsan31 - I'm checking on the 16.7 issue now. We will update the ticket as soon as we know anything.
Closing this runtime issue. Keep an eye on your two designer feedback tickets, they are now being looked at. We'll keep you posted there.
@merriemcgaw
Closing this runtime issue. Keep an eye on your two designer feedback tickets, they are now being looked at. We'll keep you posted there.
Sorry, but I am not understand why you closed this? This is separate issue and not designer related.
The problems here (appear only if new form's Font != DefaultFont
) are:
this.Controls.Add(this.dataGridView1);
- Styles fonts will not apply.So, the only way to make it work:
this.Controls.Add(this.dataGridView1);
.And yes, strictly speaking this is not regression, but in core it's become more valuable because of def. font changed...
Shoot - I'm sorry. I must have gotten my wires crossed. I'll reopen. I don't know if we have time to get it into 5.0 RC2 or not, but we can investigate the runtime portion. I'll also update the title to make it clear. Sorry for the confusion!
@kirsan31 I've run your repro both from a cli and from VS 16.7.1, and both net472 and netcoreapp3.1 render the same, so this doesn't look like a regression:
What am I missing?
@RussKie You are missing nothing ;) Full explanation in this comment.
The bug persist in both .net and core (must have Font != DefaultFont
). But in .net very few ppl. can catch it, since there was no obvious need to change the font of the form (Font == DefaultFont
). But in core during migration process from net we immediately caught it when changed form font to .net default.
Yes, I eventually arrived to the appreciation of the issue. Our code hasn't changed since .NET Framework: https://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/DataGridViewMethods.cs,15585. This implementation is what's causing the problem - upon change of font (e.g. form's font changed) we're replacing the configured styles.
Yea I see. And OnFontChanged
calling too in this.Controls.Add(this.dataGridView1);
...
Good job :+1:
Verified the issue with .NET SDK 5.0.100-rtm.20513.7 that the issue has been fixed that in runtime, the font of DataGridView ColumnHeaders, Cell, Rowheaders is changed as design time
---UPD--- Clarifications: https://github.com/dotnet/winforms/issues/3033#issuecomment-689333353
.NET Core Version: 3.1.2
Have you experienced this same bug with .NET Framework?: Yes, must set font of the form != DefaultFont
Problem description: dataGridView doesn't respect font settings in Styles (
DefaultCellStyle, ColumnHeadersDefaultCellStyle...
):Expected behavior: dataGridView must respect font settings.
Windows 7 x64.
Minimal repro: WinFormsCoreTest3.zip