Replacing a TreeNode by index in a TreeView adds a blank space below node
See original GitHub issue.NET version
7.0.100-preview.5.22307.18
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 setting a new TreeNode
by index in TreeNodeCollection
, the old node seems to be not completely removed, leaving a blank space. It also creates an issue from accessibility side, because focusing on this blank space with Narrator throws an unhandled exception.
Actual behavior: Button click executes following code:
treeView1.Nodes[0] = new TreeNode(new Random().Next().ToString());
- New blank space is added every time node is replaced
- App throws an exception when blank space is focused with Narrator
- There is a memory leak because old node’s accessible object is not disconnected
Expected behavior: Button click executes following code to show expected behavior:
treeView1.Nodes.RemoveAt(0);
treeView1.Nodes.Insert(0, new TreeNode(new Random().Next().ToString()));
- No blank space
- No exceptions with Narrator
- Old node’s accessible object is disconnected preventing from memory leak
Also, replacing an item by index in other collection-based controls like ListView
or ListBox
works without issues.
Steps to reproduce
Run attached project, click on the Replace button.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
c# - How do I set an image for some but not all nodes in a ...
This can be done by going to the treeviews property panel and clicking the Icon in the panel that looks like a lighting...
Read more >(Dropdown Treeview) the text of the drop down is blank ...
I am seeing an issue with having a Drop Down Tree View and having the ... and then after, the drop down text...
Read more >Treeview Node Move Up/Down and selection on node gets ...
The Insert operation returns you a new TreeNode - try using SelectNode on the newly inserted node.
Read more >Adding rows using insert() in Tkinter Treeview
We can use insert() to add one parent of main node ( row ) to the Treeview. Here we have one student record...
Read more >Add child to parent node(treeview) when object is dropped ...
I have a palette from which I can drag a shape(eg roundedrectangle) into my diagram on right side and a tree node present...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Verified on .NET 8.0 latest build from main branch: NET 8.0.100-alpha.1.22451.15, issue was expected, test result is same as above screenshot.
@MelonWang1 - thank you for the additional investigation!