views:

152

answers:

1

I'm having an issue with the TreeView in Visual Studio 2008. I'm adding the TreeView to my form, loading it with data at runtime, and then the last object in the list ends up being farther down than the scroll bar will go. The only way to see this object is by opening up one of the other nodes and closing it. Does anyone know a way of avoiding this issue?

+2  A: 

Not seen this behaviour before, sounds like it could be a drawing issue. Can you post some code to demonstrate what you're doing to ensure there is nothing crazy going on?

One thing I might suggest trying is to call a treeview.SuspendLayout() and ResumeLayout() once you've added your nodes. See if that makes any difference.

EDIT

Spotted this Issue

Suggestions to fix are:

i) Disabling visual styles.
ii) Adding an empty node to the end of the list.

Ian
I like your idea of SuspendLayout and ResumeLayout. I looked and that is not being done in the section of code that loads the TreeView that doesn't display all the nodes, but is done in another part of the app that loads the list just fine. I haven't tried it yet but I'm going to try and add that in when I get a chance.
norlando02
Generally if you're adding a lot of nodes to the treeview it helps improve the performance slightly, and I think it prevents it from drawing after each node which will reduce flicker.
Ian
The SuspendLayout and ResumeLayout worked.
norlando02
Really? I wasn't expecting that to work actually, once I'd found it was an issue. If so you should follow the link through to the issue and post it as a workaround :)
Ian