make TreeView stay at top

  • Thread starter Thread starter jp2msft
  • Start date Start date
J

jp2msft

I have a TreeView control that I am populating with a lot of data.

I have been asked to expand the nodes so management can quickly access the
individual elements.

This is easy to do with TreeView1.ExpandAll(); however, the TreeView control
scrolls the last part of the data into focus.

How do I either prevent this scrolling or reset the TreeView control's view?
 
Found a quick fix already:

After TreeView1.ExpandAll(),
set TreeView1.TopNode = TreeView1.Nodes[0];

If there is something better (or other ideas), I always enjoy hearing them!
 
jp2msft avait prétendu :
I have a TreeView control that I am populating with a lot of data.

I have been asked to expand the nodes so management can quickly access the
individual elements.

This is easy to do with TreeView1.ExpandAll(); however, the TreeView control
scrolls the last part of the data into focus.

How do I either prevent this scrolling or reset the TreeView control's view?

Hi jp2msft,

By default, TreeView control doesn't focus last tree node. Perhaps, you
make something that makes this behavior.

To prevent scrolling you can insert javascript like this at the bottom
your page :
<script>
window.scroll(0,0);
</script>
 
Well... I forgot to say that this is a WinForm and not a WebForm, so I don't
use JavaScript. I suppose what you gave was still an answer, though.

I was able to get "TreeView1.TopNode = TreeView1.Nodes[0];" to work for me,
though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top