Closed ghost closed 9 months ago
@roland5572 Thanks for reporting this!
As this isn't a regression from .NET Framework it is unlikely that the WinForms team will be able to get to the issue. If you or another community member wants to investigate a possible fix we'll be happy to look at any pull requests.
Note that all changes to existing behavior are considered breaking changes and have to be evaluated for potential impact to existing applications. See Behavior breaking change for the guidelines we follow.
This issue is now marked as "up for grabs", and we’re looking for a community volunteer to work on this issue. If we receive no interest in 120 days, we will close the issue. To learn more about how we handle feature requests, please see our documentation.
Happy Coding!
Verified this issue on .NET 9.0.100-preview.2.24101.9 with dlls built from winforms repo of main branch, it was fixed that: view.Sorted is false when set TreeViewNodeSorter to null.
Verified this issue with .NET 9 Preview 2 test pass build, it was fixed. Test result is same as above.
.NET version
6.0 / 4.8
Did it work in .NET Framework?
No
Issue description
If you have a TreeView control, and you set TreeView.TreeViewNodeSorter = new TreeNodeComparer(). Then .net will set TreeView.Sorted=true.
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.treeview.treeviewnodesorter
But if you set TreeView.TreeViewNodeSorter = null, Then .net will not set TreeView.Sorted=false. This means .net will still sort all nodes.
So if you have set TreeView.TreeViewNodeSorter = new TreeNodeComparer(), you may need to call two steps:
Then you can cancel the automatic sorting function of TreeView.
But TreeView.Sorted Property has Attribute [EditorBrowsable(EditorBrowsableState.Never)], So you may not find this property in a text editor.
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.treeview.sorted
Steps to reproduce
Full Test .net code: .net 6.0 with Visual studio 2022