|
-
Jan 13th, 2008, 04:20 PM
#1
[RESOLVED] TreeView right mice button click
When you right click your mice over some Node in a TreeView it gets selected for a brief moment (talking about the region that is not the "Text" of that Node - if you have FullRowSelect at True of course).
I know there is a way i can keep it selected, just don't know how 
Thanks!
-gav
-
Jan 13th, 2008, 04:33 PM
#2
Re: TreeView right mice button click
Do you have "HideSelection" set to False?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 13th, 2008, 06:12 PM
#3
Re: TreeView right mice button click
On a right mouse click, the DropHighlight property is set to the node that was clicked upon but only within the MouseUp event. It does not matter if FullRowSelect is true or false.
Code:
Private Sub TreeView1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbRightButton Then
If Not TreeView1.DropHighlight Is Nothing Then
TreeView1.DropHighlight.Selected = True
End If
End If
End Sub
If you need to find the clicked upon node in the MouseDown event use this code
Code:
Private Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim lngIdx As Long
Dim oNode As Node
If Button = vbRightButton Then
Set oNode = TreeView1.HitTest(x, y)
If oNode Is Nothing Then
'click did not occur directly on a node's text
'check if it may have occurred elsewhere along the node's row
For lngIdx = 1 To TreeView1.Width Step 100
Set oNode = TreeView1.HitTest(lngIdx, y)
If Not oNode Is Nothing Then
oNode.Selected = True
Exit For
End If
Next
Else
oNode.Selected = True
End If
End If
End Sub
-
Jan 13th, 2008, 06:14 PM
#4
Re: TreeView right mice button click
 Originally Posted by RobDog888
Do you have "HideSelection" set to False?
It doesn't matter. HideSelection only hides (if set to True) the "selection" of the selected item when TV looses focus. That's not my problem
-
Jan 13th, 2008, 06:17 PM
#5
Re: TreeView right mice button click
@brucevde: u can't miss, can u thanks
-
Jan 13th, 2008, 06:22 PM
#6
Re: [RESOLVED] TreeView right mice button click
You win some, you lose some.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|