471,357 Members | 1,161 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,357 software developers and data experts.

make TreeView stay at top

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?
Sep 17 '08 #1
3 5722
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" wrote:
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?
Sep 17 '08 #2
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>

--
Paul Musso
Sep 17 '08 #3
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.

"Paul Musso" wrote:
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>

--
Paul Musso
Sep 17 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by sonali_reddy123 | last post: by
reply views Thread by Gabriel Lozano-Morán | last post: by
reply views Thread by Elliot | last post: by
5 posts views Thread by lanem | last post: by
1 post views Thread by mongphong28 | last post: by
reply views Thread by J | last post: by
5 posts views Thread by Max2006 | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.