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
TreeNodeCollection.AddRange works incorrectly for non-empty collection of the sorted TreeView #8768
Comments
Thanks for filing this issue. I will hand this over to the community if someone has ideas for how to fix this and put it under a configuration switch. Given that this has been the behvavior since .NET Framework days, the team will not be able to prioritize it on our end. |
This issue is now marked as "help wanted", and we’re looking for a community volunteer to work on this issue. If we receive no interest in 180 days, we will close the issue. To learn more about how we handle feature requests, please see our documentation. Happy Coding! |
This comment was marked as outdated.
This comment was marked as outdated.
See #8556 for examples of context switches. |
@Tanya-Solyanik Can you please review my PR. |
@RutulPatel8 - is this issue fixed by PR #11253? |
I'm not sure, but I can say one thing: There have been lots of changes made with these PRs, and I've made the same change by altering a single 'if' condition. Could you please review my PR?" |
I had verified again, this is reproing in .NET Framework, my experiment was wrong because I re-sorted the TreeView after adding the unsorted range |
@Tanya-Solyanik It means still you have facing the same issue and my changes wasn't working with.net framework? |
@RutulPatel8 - your change is good, except for the failing tests. All failing tests are related to treeviews and that they are not failing for other PRs. |
Moving to triage to confirm that we don't want an opt-in switch for this change. |
This has been present since .NET Framework so we will need an opt-out switch for this behavior. @Tanya-Solyanik suggests This will potentially be a breaking change, but the current behavior is not what we'd expected. |
@RutulPatel8, are you planning on picking this one up, or should we have a team member wrap up the work? Thanks! |
.NET version
6.0
Did it work in .NET Framework?
No
Did it work in any of the earlier releases of .NET Core or .NET 5+?
No
Issue description
When the tree nodes are appended to the non-empty
TreeNodeCollection
owned by the sortedTreeView
with already created underlying window, the resulting order of items in the actual window does not match the one in the collection (which is correct).The cause is how method
TreeNode.PrevNode
works: when called from withinTreeNodeCollection.AddRange
of non-empty collection, it always uses fixed index as the position of the previous node, assuming the normal backward insertion of the nodes in the unsorted tree. Yet in case of the sortedTreeView
, insertions are made at various positions according to a sort order.There obviously should be a check for the sorted state of the tree in
TreeNode.PrevNode
to avoid this.Steps to reproduce
This results in:
The text was updated successfully, but these errors were encountered: