Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio 2022 Winform designer generates code for DataGridView.AutoGenerate = false is incorrect #13009

Open
MauNguyenVan opened this issue Feb 22, 2025 · 2 comments
Labels
area-VSDesigner Windows Forms out-of-proc designer related issues
Milestone

Comments

@MauNguyenVan
Copy link

Environment

Microsoft Visual Studio Enterprise 2022 (64-bit) - Current

Project type: Winform .net core 8.0

.NET version

Winform .net core 8.0 but i belive .Net 9.0 has the same the issuse

Did this work in a previous version of Visual Studio and/or previous .NET release?

yes.

Issue description

In Winform Designer, when adding a new DataGridView control, then setting the property ‘DataGridView.AutoGenerate’ becomes ‘false’, the code generated is incorrect:
Instead of generating ‘dataGridView1.AutoGenerate = false’ into the ‘InitializeComponent()’
it declares a new local variant ‘DataGridView1 dataGridView1;’ the adding new variant ‘dataGridView1’ is the same name as the field ‘dataGridView1’ added by the designer before, thus field ‘dataGridView1’ is never initialized => at runtime throw a Null Ex.

I have recorded my screen below the file attachment (I recorded on another computer, but the other VS version (the newest) still met the same issue).

Steps to reproduce

in VS designer

  • Add a datagridview in form.
  • Change the property ``GenerateMemberof datagridview fromtrue` to `false`
  • Check the code generated for the datagridview in method InitializeComponent()
IncorrectDataGridView.AutoGenerate1.mp4

Diagnostics


@MauNguyenVan MauNguyenVan added the untriaged The team needs to look at this issue in the next triage label Feb 22, 2025
@elachlan elachlan added the area-VSDesigner Windows Forms out-of-proc designer related issues label Feb 23, 2025
@John-Qiao
Copy link
Member

This is a known issue, and we had filed GH DT issue: 2177 for it.

@merriemcgaw
Copy link
Member

Thanks @John-Qiao for confirming. @MauNguyenVan we don't have a specific timeline in mind for this issue. We will update this when we have addressed it and let you know when you can expect a fix in VS.

@merriemcgaw merriemcgaw added this to the VS release milestone Feb 25, 2025
@merriemcgaw merriemcgaw removed the untriaged The team needs to look at this issue in the next triage label Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-VSDesigner Windows Forms out-of-proc designer related issues
Projects
None yet
Development

No branches or pull requests

4 participants