Have found DirView a handy way of displaying directories.
Is there a way to select (in code) a particular directory in the display?
DirView question
-
- Posts: 215
- Joined: Tuesday 26th September 2017 3:17pm
- Location: NW England
- BruceSteers
- Posts: 1877
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: DirView question
Yes by accessing the Dirview's internal TreeView objectbill-lancaster wrote: ↑Monday 20th May 2024 9:01am Have found DirView a handy way of displaying directories.
Is there a way to select (in code) a particular directory in the display?
Public Sub Form_Open()
DirView1.ShowHidden = True
SelectDir(User.home &/ ".config", DirView1)
End
Private Sub SelectDir(Path As String, DView As DirView)
Dim tv As TreeView = DView.Children[0]
tv[Path].Selected = True
End
If you look at the DirView source code...
https://gitlab.com/gambas/gambas/-/blob ... =heads#L93
You can see that when it is is created is first adds 1 TreeView object to itself, so the DirView.Children[0] is a TreeView.
So with the above code..
Dim tv As TreeView = DView.Children[0]
tv is the TreeView, you can do all you can with a normal TreeView.
Dim tv As TreeView = DView.Children[0]
Print tv.Keys.Join("\n") ' list all the item keys
tv[Path].Background = Color.yellow ' make one item have yellow background
tv[Path].RichText = "<font color=green><b>" & tv[Path].Text & "</b></font>" ' change font color of one item and make it bold.
If at first you don't succeed , try doing something differently.
BruceS
BruceS
-
- Posts: 215
- Joined: Tuesday 26th September 2017 3:17pm
- Location: NW England
Re: DirView question
Does the trick nicely,
Thanks Bruce
Thanks Bruce