I have a System.Windows.Forms.TreeView
docked inside a panel. I am setting a node selected programmatically. What method or property would I use to have the treeview scroll the selected into view?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
I had some issues with
node.EnsureVisible()
not working for trees with only one level of nodes.To fix this use the
BindingIndex
to identify the node selected. Then the node selected will be scrolled in view.The example shows
myTable
from a LINQ query.I hope this helps some of you.
I also had issues with this and figured out that treeview.ExpandAll() ignores the EnsureVisible() effect and avoids the scrolling to the node position.
Just call EnsureVisible() after ExpandAll() if you want a full expanded tree with the scroll on the node you've selected.
for example:
(see MSDN)