docs-desktop
docs-desktop copied to clipboard
Bad setting leading to full load of data regardless of Virtual Mode
There's a vital piece of optimization that is done wrong in this example - the DataGridView.AutoSizeColumnMode is set to .AllCells. That requires loading the entire set of rows, not just the displayed window, to calculate cell widths. That means the CellValueNeeded event is called for every cell in every row of the data upon initialization; hardly the desired behavior for a Virtual Mode table.
The AutoSizeColumnMode should be set to .DisplayedCells or .None, so display only requires fetching a few lines. The speed difference in my code for setting the .RowCount value (~50K rows, 10 columns, 8 lines displayed) was 45 seconds for AllCells versus ~4 milliseconds for DisplayedCells. This should be a key recommendation for Virtual Mode. [Enter feedback here]
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: aec74745-9e0c-9e4a-d749-d877ea4c3d38
- Version Independent ID: 1e13259c-5787-d1d8-06ba-b4d13f7ba011
- Content: Walkthrough: Implement virtual mode in DataGridView control - Windows Forms .NET Framework
- Content Source: dotnet-desktop-guide/framework/winforms/controls/implementing-virtual-mode-wf-datagridview-control.md
- Product: dotnet-framework
- Technology: dotnet-winforms
- GitHub Login: @adegeo
- Microsoft Alias: adegeo
Thank you for the this suggestion. Enhancing this article is a low priority right now. If you would like to contribute, you can submit a fix by editing the original article. Click on the Content Source link at the bottom of your original comment. To learn how to edit, see the Editing files in a repository article from GitHub.
Done. The guide to DataGridView Best Practices already says to avoid .DataGridViewAutoSizeColumnsMode.AllCells, now the edited Cpp, C#, and VB examples use .DisplayedCells instead.
Kevin Ryan Senior Software Engineer 8700 Morrissette Drive Springfield, VA 22152 T. 703.440.0222 x61024 C. 301.455.9848 @.*** www.sonix.com
From: Andy (Steve) De George @.> Sent: Monday, September 12, 2022 2:52 PM To: dotnet/docs-desktop @.> Cc: Ryan, Kevin @.>; Author @.> Subject: [EXTERNAL] Re: [dotnet/docs-desktop] Bad setting leading to full load of data regardless of Virtual Mode (Issue #1501)
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
Thank you for the this suggestion. Enhancing this article is a low priority right now. If you would like to contribute, you can submit a fix by editing the original article. Click on the Content Source link at the bottom of your original comment. To learn how to edit, see the Editing files in a repositoryhttps://urldefense.com/v3/__https:/help.github.com/articles/editing-files-in-your-repository__;!!KPww_GFiJXw!flgfLPhG4B-2FVvm0T617BbzNeKrMY1CMcxRTblyOc7Wam8nW7VYgoOHPQjvmqk_TJLKk_4USg0XWibpiCy0cG2v$ article from GitHub.
— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/dotnet/docs-desktop/issues/1501*issuecomment-1244156581__;Iw!!KPww_GFiJXw!flgfLPhG4B-2FVvm0T617BbzNeKrMY1CMcxRTblyOc7Wam8nW7VYgoOHPQjvmqk_TJLKk_4USg0XWibpiM0gm1py$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AJMYDSDR5IU5VZGCGSPTO4DV553UXANCNFSM6AAAAAAQG4DGOU__;!!KPww_GFiJXw!flgfLPhG4B-2FVvm0T617BbzNeKrMY1CMcxRTblyOc7Wam8nW7VYgoOHPQjvmqk_TJLKk_4USg0XWibpiBqCyTjg$. You are receiving this because you authored the thread.Message ID: @.@.>>
Please be advised that this email may contain confidential information. If you are not the intended recipient, please notify us by email by replying to the sender and delete this message.
Hi! I didn't see a PR come through for the changes? Are you sure you made them?
I thought I did – I corrected the three code samples, added a comment for each, and thought I had committed them. I will note, however, that I haven’t worked with GitHub before, and may have failed to complete the edit??
I’m currently swamped, though, and won’t be able to dig into this for a while.
Kevin Ryan Senior Software Engineer 8700 Morrissette Drive Springfield, VA 22152 T. 703.440.0222 x61024 C. 301.455.9848 @.*** www.sonix.com
From: Andy (Steve) De George @.> Sent: Monday, September 12, 2022 4:48 PM To: dotnet/docs-desktop @.> Cc: Ryan, Kevin @.>; Author @.> Subject: [EXTERNAL] Re: [dotnet/docs-desktop] Bad setting leading to full load of data regardless of Virtual Mode (Issue #1501)
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
Hi! I didn't see a PR come through for the changes? Are you sure you made them?
— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/dotnet/docs-desktop/issues/1501*issuecomment-1244441614__;Iw!!KPww_GFiJXw!b9K-xdFNidtJvm8Z-WDKQeBK5rsVOGgUvMyn5hUxNHDR0KhQHPeQ9fxMRtKXq0z0aWJoAht99zGyzvX8-ogQXFNT$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AJMYDSC22XSHZDWFUZMNAZ3V56JGTANCNFSM6AAAAAAQG4DGOU__;!!KPww_GFiJXw!b9K-xdFNidtJvm8Z-WDKQeBK5rsVOGgUvMyn5hUxNHDR0KhQHPeQ9fxMRtKXq0z0aWJoAht99zGyzvX8-lzHrShu$. You are receiving this because you authored the thread.Message ID: @.@.>>
Please be advised that this email may contain confidential information. If you are not the intended recipient, please notify us by email by replying to the sender and delete this message.
Thank you for putting in the effort :) I can see your updates in your copy of the repository. Those need to be ported into this one through a PR. I can actually open them up for you since you're busy.
PR = Pull request? Push request? If you can incorporate those, that would be fantastic.
I've had GitHub on my "to learn" list for a while, but haven't had a need to make it a priority... perhaps I should change that.
Kevin Ryan
Sent from my Metro By T-Mobile 4G LTE Android Device Get Outlook for Androidhttps://aka.ms/AAb9ysg
From: Andy (Steve) De George @.> Sent: Tuesday, September 13, 2022 1:16:28 PM To: dotnet/docs-desktop @.> Cc: Ryan, Kevin @.>; Author @.> Subject: [EXTERNAL] Re: [dotnet/docs-desktop] Bad setting leading to full load of data regardless of Virtual Mode (Issue #1501)
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
Thank you for putting in the effort :) I can see your updates in your copy of the repository. Those need to be ported into this one through a PR. I can actually open them up for you since you're busy.
— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/dotnet/docs-desktop/issues/1501*issuecomment-1245709349__;Iw!!KPww_GFiJXw!eetNio8JkxxLOXkhTRPDwv5ZQx1sTZGnUEaOh_7IGtRIiUai0zQWPhhH4y0ukfGD1VNFWabCwjU9wK3UTAcGDUYK$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AJMYDSFCUOM4OVR2TQ4LKY3V6CZGZANCNFSM6AAAAAAQG4DGOU__;!!KPww_GFiJXw!eetNio8JkxxLOXkhTRPDwv5ZQx1sTZGnUEaOh_7IGtRIiUai0zQWPhhH4y0ukfGD1VNFWabCwjU9wK3UTNMVJsWE$. You are receiving this because you authored the thread.Message ID: @.***>
Please be advised that this email may contain confidential information. If you are not the intended recipient, please notify us by email by replying to the sender and delete this message.
Correct, pull request, meaning request that your changes are pulled into the main repository.
With the way that you created your fixes (you did a separate branch for each file) I merged all three branches into a single temp branch here. I think this may remove you from the contributor history 😦 So to fix that, please use this link to open a final pull request from this temp branch to the main branch: https://github.com/dotnet/docs-desktop/compare/temp-merge?expand=1
In the fixes text, you can reference this issue id: 1501 but don't worry, I can edit the text and get it all hooked up for you if you can't figure it out. Just click that link and open the PR
Don’t worry about crediting me – I’ll be satisfied just to see the correction(s) done. That particular setting issue wasted half a day for me; if I can save others that hassle, great.
Kevin Ryan Senior Software Engineer 8700 Morrissette Drive Springfield, VA 22152 T. 703.440.0222 x61024 C. 301.455.9848 @.*** www.sonix.com
From: Andy (Steve) De George @.> Sent: Wednesday, September 14, 2022 4:17 PM To: dotnet/docs-desktop @.> Cc: Ryan, Kevin @.>; Author @.> Subject: [EXTERNAL] Re: [dotnet/docs-desktop] Bad setting leading to full load of data regardless of Virtual Mode (Issue #1501)
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
With the way that you created your fixes (you did a separate branch for each file) I merged all three branches into a single temp branch here. I think this may remove you from the contributor history 😦 So to fix that, please use this link to open a final pull request from this temp branch to the main branch: https://github.com/dotnet/docs-desktop/compare/temp-merge?expand=1https://urldefense.com/v3/__https:/github.com/dotnet/docs-desktop/compare/temp-merge?expand=1__;!!KPww_GFiJXw!f3H-oPUB5vn681EyUsPvlRXlgzmAo3VjlfCH48lwy8rP8axVPN56J7GH3T0NgCxI7nRw3HZUdO0b-diFSVdrw7ss$
In the fixes text, you can reference this issue id: 1501 but don't worry, I can edit the text and get it all hooked up for you if you can't figure it out. Just click that link and open the PR
— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/dotnet/docs-desktop/issues/1501*issuecomment-1247256539__;Iw!!KPww_GFiJXw!f3H-oPUB5vn681EyUsPvlRXlgzmAo3VjlfCH48lwy8rP8axVPN56J7GH3T0NgCxI7nRw3HZUdO0b-diFSdJ66xp4$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AJMYDSGZEOZHYBSW36PSSJTV6IXC5ANCNFSM6AAAAAAQG4DGOU__;!!KPww_GFiJXw!f3H-oPUB5vn681EyUsPvlRXlgzmAo3VjlfCH48lwy8rP8axVPN56J7GH3T0NgCxI7nRw3HZUdO0b-diFSWH8G9QC$. You are receiving this because you authored the thread.Message ID: @.@.>>
Please be advised that this email may contain confidential information. If you are not the intended recipient, please notify us by email by replying to the sender and delete this message.