SEARCH in treeview
-
- PlatinumLounger
- Posts: 4470
- Joined: 26 Apr 2010, 17:36
SEARCH in treeview
How to search myvar in each level 3 of treeview?
Tks
Tks
-
- Administrator
- Posts: 79287
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4470
- Joined: 26 Apr 2010, 17:36
Re: SEARCH in treeview
ok.
I USE THIS CODE TO SEARCH IN TREEVIEW.
if the value is found i set green font.
Only a problem...
if the treeview is compressed when the node is found i need to expand the root CN-CUNEO , to permit to the user to see the item found
How to?
Code: Select all
End Sub
Private Sub CERCA_COMUNI()
Dim MYNODE As Node
Dim NRTOT As Long
VALORE = "004003"
NRTOT = 0
For Each MYNODE In Me.TreeView1.nodes
If MYNODE.children = 0 Then
NRTOT = NRTOT + 1
ISTAT = Split(MYNODE, "-")(0)
If ISTAT = VALORE Then
Stop
NR = MYNODE.Index
MYNODE.BackColor = vbGreen
Exit For
End If
End If
DoEvents
Next
End Sub
Last edited by sal21 on 19 Jul 2024, 10:14, edited 1 time in total.
-
- Administrator
- Posts: 79287
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4470
- Joined: 26 Apr 2010, 17:36
-
- PlatinumLounger
- Posts: 4470
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 79287
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: SEARCH in treeview
That will work if "063009-BOSCOTRECASE" is the Key of a node, not if it is the text of a node.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4470
- Joined: 26 Apr 2010, 17:36
-
- PlatinumLounger
- Posts: 4470
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 79287
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4470
- Joined: 26 Apr 2010, 17:36
-
- PlatinumLounger
- Posts: 4470
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 79287
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: SEARCH in treeview
Yes. If you do that, you can later on use
VV = "600223"
Set MYNODE = Me.TreeView1.Nodes.Item(VV)
or even
VV = "600223"
Set MYNODE = Me.TreeView1.Nodes(VV)
VV = "600223"
Set MYNODE = Me.TreeView1.Nodes.Item(VV)
or even
VV = "600223"
Set MYNODE = Me.TreeView1.Nodes(VV)
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4470
- Joined: 26 Apr 2010, 17:36
-
- 5StarLounger
- Posts: 610
- Joined: 14 Nov 2012, 16:06
Re: SEARCH in treeview
e.g.
Code: Select all
Private Sub UserForm_Click()
With TV_01.Nodes("DOLO")
.EnsureVisible
.BackColor = vbGreen
End With
End Sub