By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,905 Members | 2,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,905 IT Pros & Developers. It's quick & easy.

TreeView Control: How to force tb scrolled left?

P: n/a
I've got a TreeView in which I present a rather wide line of info for some
branches. The user doesn't care to see all the info all of the time and we're
tight on horizontal screen space, so we've elected to just let the user scroll
right if they want to see more info.

The glitch is that we open up the form and populate the TreeView control, it is
left in a scrolled state - in this case, just enough to hide the plus signs that
indicate child nodes...

Seems like there should be a way to keep the horizontal scroll bar, but force it
all the way left after we populate the TreeView... I'm guessing I could dope
something out using SendKeys, but I'd rather not go there if I don't have to.

Some hidden method/property?
--
PeteCresswell
Jul 15 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Actually the behavior you report is not the default. You are probably
doing some "EnsureVisible" after adding a node, to cause the scroll.

Remove it, to avoid scrolling. If possible use .addrange and do node
selection / ensurevisible when finished adding nodes. Let me know...

-tom

(PeteCresswell) ha scritto:
I've got a TreeView in which I present a rather wide line of info for some
branches. The user doesn't care to see all the info all of the time and we're
tight on horizontal screen space, so we've elected to just let the user scroll
right if they want to see more info.

The glitch is that we open up the form and populate the TreeView control, it is
left in a scrolled state - in this case, just enough to hide the plus signs that
indicate child nodes...

Seems like there should be a way to keep the horizontal scroll bar, but force it
all the way left after we populate the TreeView... I'm guessing I could dope
something out using SendKeys, but I'd rather not go there if I don't have to.

Some hidden method/property?
--
PeteCresswell
Jul 15 '06 #2

P: n/a
Per to**************@uniroma1.it:
>Actually the behavior you report is not the default. You are probably
doing some "EnsureVisible" after adding a node, to cause the scroll.

Remove it, to avoid scrolling. If possible use .addrange and do node
selection / ensurevisible when finished adding nodes. Let me know...
I did find/eliminate a .EnsureVisible - but it was in the Expand/Collapse All
routine that I had in place. And, indeed, after invoking that routine the
tree's horizontal scroll is now positioned so that the high-level plus signs are
visible as long as it was so positioned in the first place (it was indeed
getting scrolled with the .EnsureVisible applied..)

But .EnsureVisible does not seem to be the culprit when I'm building the tree
and haven't done any Expand/Collapse on it yet - at least when I do a "Find" on
the code for .EnsureVisible, there aren't any hits.

Gave .vScrollPolicy = "Off" a try, but that prop doesn't seem to exist on the
ComCtl tree.

--
PeteCresswell
Jul 16 '06 #3

P: n/a
If you just add nodes without any following selection / expansion /
ensurevisible
there is no way it would scroll.

Ensure that you do nothing when adding nodes and possibly use addrange
(which is much faster, as it would not fire events after each node
addition)
Finally, if you want to really cut away any problem you can do just one
simple thing:

Me.TreeView1.Scrollable = False
'YOUR CODE HERE ...
Me.TreeView1.Scrollable = True

this will prevent scrolling during the treeview building.

-t

(PeteCresswell) ha scritto:
Per to**************@uniroma1.it:
Actually the behavior you report is not the default. You are probably
doing some "EnsureVisible" after adding a node, to cause the scroll.

Remove it, to avoid scrolling. If possible use .addrange and do node
selection / ensurevisible when finished adding nodes. Let me know...

I did find/eliminate a .EnsureVisible - but it was in the Expand/Collapse All
routine that I had in place. And, indeed, after invoking that routine the
tree's horizontal scroll is now positioned so that the high-level plus signs are
visible as long as it was so positioned in the first place (it was indeed
getting scrolled with the .EnsureVisible applied..)

But .EnsureVisible does not seem to be the culprit when I'm building the tree
and haven't done any Expand/Collapse on it yet - at least when I do a "Find" on
the code for .EnsureVisible, there aren't any hits.

Gave .vScrollPolicy = "Off" a try, but that prop doesn't seem to exist on the
ComCtl tree.

--
PeteCresswell
Jul 16 '06 #4

P: n/a
Per to**************@uniroma1.it:
>Me.TreeView1.Scrollable = False
Different type of TreeView object, I guess:
-----------------------------------------------------------
Error# 438: Object doesn't support this property or method
-----------------------------------------------------------

This is getting "interesting".... -)
--
PeteCresswell
Jul 16 '06 #5

P: n/a
Per (PeteCresswell):
>type of TreeView object
MSComctlLib.TreeCtrl.2
--
PeteCresswell
Jul 16 '06 #6

P: n/a
hi Pete,

Yes, probably. I am most familiar with the treeview in .net framework
(and with that in asp.net). Perhaps, the treview is more complete there
and has properties and methods that are not available in the version
you are using. Look for something (if present) that would disable
scrolling while you build the tree. By chance, do you have available
the addrange() method?

-tom

(PeteCresswell) ha scritto:
Per (PeteCresswell):
type of TreeView object

MSComctlLib.TreeCtrl.2
--
PeteCresswell
Jul 16 '06 #7

P: n/a
Per to**************@uniroma1.it:
>By chance, do you have available
the addrange() method?
I'm guessing not, because it does not reveal itself in auto-completion.
e.g.
--------------------------------------------------
theTree.AddRange...

or

theTree.Nodes.AddRange
--------------------------------------------------
--
PeteCresswell
Jul 16 '06 #8

P: n/a
Perhaps time to move to the .net ? :-)

(PeteCresswell) ha scritto:
Per to**************@uniroma1.it:
By chance, do you have available
the addrange() method?

I'm guessing not, because it does not reveal itself in auto-completion.
e.g.
--------------------------------------------------
theTree.AddRange...

or

theTree.Nodes.AddRange
--------------------------------------------------
--
PeteCresswell
Jul 17 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.