You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Editing form with DataGridView causes many unwanted changes #13170
Did this work in a previous version of Visual Studio and/or previous .NET release?
Framework.
Issue description
The WinForm designer for DataGridView adds additional row and column styles with every edit of the form (even if DGV is untouched) and creates new DataGridViewStyles with every edit. After first edit they are numbered 1 to N, next edit N to 2N, next edit 1 to N again if you don’t add any new styles. If you do the numbering gets more mixed up. The file size grows rapidly and it’s difficult to use Git difference because there are so many changes that need to be deleted.
Steps to reproduce
Create a for with DataGridView and anything else, edit anything and save. Upload to GitHub, edit anything, except DGV and save. Do diff and you will see many changes. Edit anything and you will see fewer diffs against GitHub. Each edit/save will cause unwanted changes.
@Olina-Zhang can you repro for us. Please let us know if/when this regressed and whether it is VB only or also C# @KlausLoeffelmann this looks like something up your alley.
Every save, you can change multiple items but as soon as you save it happens. If you undo the edit and then save again more things change. So undo does not really undo.
@Olina-Zhang can you repro for us. Please let us know if/when this regressed and whether it is VB only or also C#
Yes, we can repro it in .NET versions for C# and VB, and also repro in .NET framework 4.8.1.
When DataGridView has some additional row or column styles setting, upload app to github, then modify form, can see some extra DataGridView code change.
@merriemcgaw this is the cause of subtle bugs, if the application adds row or column styles to ANYTHING, those styles are added at the end, the styles that are added by the bug come first, since these are visual they are harder for a developer to automatically test for and much harder to root cause.
It's unlikely that legacy .Net Framework projects are editing Forms, so they are not as affected. This bug mostly effects projects that are in active Form development, so I believe the normal priority criteria should not apply.
It's unlikely that legacy .NET Framework projects are editing Forms, so they are not as affected. This bug mostly effects projects that are in active Form development, so I believe the normal priority criteria should not apply.
@paul1956 that's a persuasive point, but changes to this component would introduce the risk of regression for those Framework projects that do get some design tweaks. There is still shared code between the two designers, and this is one of those spots.
@merriemcgaw since there is no way to know how many times a file is edited, there is no way to depend on the old behavior. If an application has somehow worked around this issue (possibly by deleting all the extra styles at runtime) then fixing it would not be breaking, since only required styles would be there. In the current code Style.Count is correct no matter how many times file is edited.
Given that this is also the case in .NET Framework, it won't be high on the priority list.
@merriemcgaw, I agree that if the behavior is the same as in Framework that we do not want to break something. But the thing here is, that something is breaking anyway, so this is then not so much of a concern anymore, but in addition, I would be additionally concerned of issues in the OOP-Designer on top, which might be ending up worse than in Framework (like out-of-sync overall state between Object Model in the Designer server-side and generated code client side).
For me this therefore not priority 3, and probably not even 2. So...I do not know...
Let's at least talk about this again, when we have the immediate "other" pressuring issues addressed, if that's OK with you?
Activity
merriemcgaw commentedon Mar 20, 2025
@Olina-Zhang can you repro for us. Please let us know if/when this regressed and whether it is VB only or also C#
@KlausLoeffelmann this looks like something up your alley.
kirsan31 commentedon Mar 21, 2025
It's c# also. But I'am not shure that it's happening on every edit.
paul1956 commentedon Mar 21, 2025
Every save, you can change multiple items but as soon as you save it happens. If you undo the edit and then save again more things change. So undo does not really undo.
Olina-Zhang commentedon Mar 21, 2025
Yes, we can repro it in .NET versions for C# and VB, and also repro in .NET framework 4.8.1.
When DataGridView has some additional row or column styles setting, upload app to github, then modify form, can see some extra DataGridView code change.
Here is just Form resizing:
paul1956 commentedon Mar 21, 2025
This happens even if you don't touch the DGV or Form. If you have a Label (Label1) on the Form and edit Label1.Text and save it happens.
There are 2 different issues the name changes in the Style variables in addition to the styles added to the rows and columns.
paul1956 commentedon Mar 22, 2025
@merriemcgaw @Olina-Zhang It also happens with TableLayoutPanel again to do with Style.
merriemcgaw commentedon Mar 26, 2025
@Olina-Zhang would you be so kind as to add this to the designer repo, and I'll assign @KlausLoeffelmann
Given that this is also the case in .NET Framework, it won't be high on the priority list.
paul1956 commentedon Mar 26, 2025
@merriemcgaw this is the cause of subtle bugs, if the application adds row or column styles to ANYTHING, those styles are added at the end, the styles that are added by the bug come first, since these are visual they are harder for a developer to automatically test for and much harder to root cause.
It's unlikely that legacy .Net Framework projects are editing Forms, so they are not as affected. This bug mostly effects projects that are in active Form development, so I believe the normal priority criteria should not apply.
merriemcgaw commentedon Mar 27, 2025
@paul1956 that's a persuasive point, but changes to this component would introduce the risk of regression for those Framework projects that do get some design tweaks. There is still shared code between the two designers, and this is one of those spots.
paul1956 commentedon Mar 27, 2025
@merriemcgaw since there is no way to know how many times a file is edited, there is no way to depend on the old behavior. If an application has somehow worked around this issue (possibly by deleting all the extra styles at runtime) then fixing it would not be breaking, since only required styles would be there. In the current code Style.Count is correct no matter how many times file is edited.
kirsan31 commentedon Mar 27, 2025
@paul1956 are you talking about this: #8593
?
Olina-Zhang commentedon Mar 27, 2025
Filed a designer issue: https://github.com/microsoft/winforms-designer/issues/6327.
paul1956 commentedon Mar 27, 2025
Partly but it was closed. It happened with anything Style related.
KlausLoeffelmann commentedon Mar 31, 2025
@merriemcgaw, I agree that if the behavior is the same as in Framework that we do not want to break something. But the thing here is, that something is breaking anyway, so this is then not so much of a concern anymore, but in addition, I would be additionally concerned of issues in the OOP-Designer on top, which might be ending up worse than in Framework (like out-of-sync overall state between Object Model in the Designer server-side and generated code client side).
For me this therefore not priority 3, and probably not even 2. So...I do not know...
Let's at least talk about this again, when we have the immediate "other" pressuring issues addressed, if that's OK with you?