I have a really weird problem with TreeView control. Has to do with how it's populated and subsequently cleared.
Context:
I have a collection of data objects (List). Each object in the collection has property that returns its associated TreeNode object. I selectively populate List<TreeNode> with these nodes and then add those nodes to TreeView:
List<TreeNode> nodes = new List<TreeNode>(capacity);
foreach (MyObject obj in myList)
{
if (obj.SomeProperty == true) // condition
nodes.Add(obj.TreeNode);
}
TreeNode[] node_array = nodes.ToArray();
TreeView.Nodes.AddRange(node_array);
At some point I clear TreeView using TreeView.Nodes.Clear();
Problem:
Whenever ALL nodes are added (condition yields true for every obj in the list), TreeView.Nodes.Clear() is very fast. However, if enough nodes are not added (when condition is false for some objects), TreeView.Nodes.Clear() is extremely slow.
This makes absolutely no sense. TreeView is cleared fast whenever all available nodes are present, yet it is very very slow whenever some nodes are missing. All nodes are completely independent from each other.
Can anyone provide an explanation as to why this happens? I've been banging my head against the wall for the last 3 hours.
I prefer the Windows Vista Startup sound. It was designed in accordance with Windows AERO principles; the sound itself, among other niceties "has two parallel melodies played in an intentional 'Win-dows Vis-ta' rhythm".
Before Windows Vista was released to manufacturing there were discussions about this Startup sound being mandatory like the startup sound of the Xbox 360. (This did not happen.)
(I recall and appreciate that it is Windows Vista that first allowed users to disable only Windows sounds from the Volume Mixer.)
For sure, Windows 7 had quite good design with its transparency, as did Vista. The early Longhorn builds and prototypes definitely went too far, but certainly looked a lot nicer. They weren't particularly practical, with some text difficult to read, with attempts to add contrast with weird drop shadow glows around text.
I believe the reason they stepped away from that was partly to do with accessibility of a standard Windows desktop having the right levels of contrast. From memory, they made a point of this in Office 2010, when Office 2007's ribbon didn't conform to access ability standards with poor contrasted text on the blue background.
Question
remix17
I have a really weird problem with TreeView control. Has to do with how it's populated and subsequently cleared.
Context:
I have a collection of data objects (List). Each object in the collection has property that returns its associated TreeNode object. I selectively populate List<TreeNode> with these nodes and then add those nodes to TreeView:
At some point I clear TreeView using TreeView.Nodes.Clear();
Problem:
Whenever ALL nodes are added (condition yields true for every obj in the list), TreeView.Nodes.Clear() is very fast. However, if enough nodes are not added (when condition is false for some objects), TreeView.Nodes.Clear() is extremely slow.
This makes absolutely no sense. TreeView is cleared fast whenever all available nodes are present, yet it is very very slow whenever some nodes are missing. All nodes are completely independent from each other.
Can anyone provide an explanation as to why this happens? I've been banging my head against the wall for the last 3 hours.
Thanks in advance.
Link to comment
https://www.neowin.net/forum/topic/656736-extremely-weird-c-problem/Share on other sites
4 answers to this question
Recommended Posts