Visual Basic .NET » Smart Device Application
windowsforms.Treeview control lookin' pretty oogly... -- rhaazy --


Using C#

I am currently using a method in which when a node is selected it ensures that only the nodes that need to be expanded to get to the selected node are expanded. It looks like this:

TreeNode objNode = (TreeNode)e.Node; //e.Node is current node treeView1.CollapseAll();
if (!objNode.IsExpanded)
{
objNode.EnsureVisible();
}
treeView1.Update();

My problem is when I get to about the 4th level I get some odd behavior, it seems to me like there is just too much for this function to handle and it takes too long to collapse and expand. In other words the treeview looks like some crazy mess of letters after I click a node, before expanding back out.

Is there another method to achieve what I'm doing or a fix to my problem? Any help would be appreciated.

Thanks in advance.

-- Cerebrus --


See the TreeView.BeginUpdate and EndUpdate methods in help. They are used to suppress re-painting of the TreeView until you've done your work. I hope that will fix the problem.

Regards,

Cerebrus.

-- rhaazy --


thank you very much, this helps... do you have a suggestion as to where I can implement these two functions..this is what I have right now, but there is still times when there are more than a few nodes where there is a flash.

treeView1.BeginUpdate();
treeView1.CollapseAll();
if (!objNode.IsExpanded)
{
objNode.EnsureVisible();

}
treeView1.EndUpdate();

[Submit Comment]Home