question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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());

Animation1

  • 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()));

Animation2

  • 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.

TreeViewReplaceBug.zip

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Nora-Zhou01commented, Sep 2, 2022

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.

1reaction
Tanya-Solyanikcommented, Aug 31, 2022

@MelonWang1 - thank you for the additional investigation!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found