Is there a way to have multiple root nodes in a TreeView?
- Add your “root” items directly to treeview’s RootNode;
- Set RootNodeVisible=False
Also, is there a way to scroll to a node in the TreeView?
For that purpose there is an EnsureVisible() base method (declared in ScrollView).
In ted2go I improved EnsureVisible – my version expand all parents before try to make visible and grab only Y-scroll.
Also, I added Selected property to my TreeViewExt class, and call ensure visible inside of it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
Property Selected:TreeView.Node() Return _sel Setter( value:TreeView.Node ) _sel = value EnsureVisible( _sel ) End Method EnsureVisible( node:TreeView.Node ) Local n:=node While n n.Expanded=True n=n.Parent Wend ' scroll Y only Local sx:=Scroll.x Local scroll:=Scroll Super.EnsureVisible( node.Rect ) scroll.Y=Scroll.y Scroll=scroll End |
For more details look at sources: \ Ted2Go \ view \ TreeViewExt.monkey2