Fix DataGridViewComboBoxCell setting incorrect value when DisplayMember values are duplicated#14630
Fix DataGridViewComboBoxCell setting incorrect value when DisplayMember values are duplicated#14630abineshPalanisamy wants to merge 4 commits into
Conversation
Added fix for the Fix_Issue_11311
Updated the review changes
Added unit test cases for the fix.
This reverts commit 2a91b34.
|
Thanks for taking this initiative! But we need to vet these kinds of bug fixes more carefully. So, this is, why are want you to ask to do the following:
What's its behavior? |
|
So, I was thinking. It is important, to get these bugs fixed. (And this a general issue, we need to address, so I will publish a literal issue, to raise awareness to this more directly.) I had a concept in mind, actually for a bit, to find an approach to do the one without risking the other. I think, there can be a good solution for this. So - I would like to suggest this to you, before we are blindly rushing into fixing APIs, which I would then need to reject because the breaking changings risk would be too large. Let's do it in close rooms, and the merge the best of both worlds later, to get an optimum of coverage. My ask:
Why the latter? Because we CANNOT AT ALL risk, that when those AI Code Assistants or Generative Code Completion tools do more or less big migration efforts effectively autonomously, no one will catch the bugs, which will be introduced, because the earlier necessary bug-workaround/mitigation WILL be migrated along, and then BECOME the bug, that will make a software become unstable, crash, or - even worse - lead in a fictional scenario, let the plutonium rods in an Atomic Power Station melt, when the power station service provider rolled out the new version, which was migrated from NetFX 4.7.2 to .NET 11... 😉 |
Fixes #11311
Proposed changes
DataGridViewComboBoxCell.LookupValueto prefer the actual selected item from the active editingComboBoxwhen the cell is in edit mode.DisplayMemberwhen multiple data source items share the same display value.Root cause
DataGridViewComboBoxCell.LookupValueresolves the committed value by performing a reverse lookup using theDisplayMember(display text).DisplayMembervalues, this lookup becomes ambiguous.Customer Impact
DataGridViewComboBoxCellwhen multiple items share the sameDisplayMembertext.Idfields or computed columns derived from the selected item) are updated from the item the user actually selected instead of the first matching display-text entry.Regression?
Risk
ComboBox.Screenshots
Before
Combo_box.before.fix.mp4
After
Combo_box.fix.mp4
Test methodology
DataGridViewComboBoxCellbound to multiple items with identicalDisplayMembervalues and distinct underlying values.Idor derived/computed values) update correctly after commit.DisplayMembervalues.Accessibility testing
Test environment(s)
Microsoft Reviewers: Open in CodeFlow