|
-
Mar 14th, 2006, 10:36 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Click TreeView Node!
In a WebBrowser project, a TreeView is used to list the History of the URLs a user has visited. Other than left-clicking any node in the TreeView to navigate to the URLs, users can also navigate by dragging & dropping a node in the WebBrowser. This is how I am implementing it:
VB Code:
Private Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If (Button = vbLeftButton) Then
TreeView1.SelectedItem = TreeView1.HitTest(x, y)
TreeView1.Drag vbBeginDrag
End If
End Sub
Private Sub wWeb_DragDrop(Source As Control, x As Single, y As Single)
If Not (Source.SelectedItem Is Nothing) Then
wWeb.Navigate2 Source.SelectedItem.Tag
End If
End Sub
The above code implements the drag-drop feature exactly as I want it but strangely, the WebBrowser doesn't navigate to the Tag of the node (which is the URL) when a node is just left-clicked.
What am I missing here?
ARPAN
IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!
NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!
PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?
-
Mar 14th, 2006, 01:39 PM
#2
Re: Click TreeView Node!
VB Code:
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
wWeb.Navigate2 Node.Tag
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Mar 14th, 2006, 02:32 PM
#3
Re: Click TreeView Node!
The Node_Click event occurs after Mouse_Down, however Node_Click will not fire because the Drag operation has taken over. Use the right mouse button for dragging.
-
Mar 14th, 2006, 03:54 PM
#4
Re: Click TreeView Node!
ahh true...
heres a question... Y "force" (Code) the drag? u can just set the control to allow drag... then u dont have to program it....
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Mar 14th, 2006, 05:07 PM
#5
Thread Starter
Frenzied Member
Re: Click TreeView Node!
heres a question... Y "force" (Code) the drag? u can just set the control to allow drag... then u dont have to program it....
Sorry, Static, I couldn't exactly follow what are you trying to say. Please clarify!
ARPAN
IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!
NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!
PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?
-
Mar 14th, 2006, 05:11 PM
#6
Thread Starter
Frenzied Member
Re: Click TreeView Node!
Use the right mouse button for dragging.
Bruce, right-mouse click is already reserved for doing something else.........
ARPAN
IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!
NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!
PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?
-
Mar 14th, 2006, 06:22 PM
#7
Thread Starter
Frenzied Member
-
Mar 15th, 2006, 01:46 AM
#8
Re: Click TreeView Node!
Bruce, right-mouse click is already reserved for doing something else.........
So is the Left-Mouse click, but now you want to use it for two different operations. Plus, for me, the ListView functions exactly the same as the Treeview. This is the code I used
VB Code:
Private Sub Form_Load()
With ListView1
.View = lvwReport
.ColumnHeaders.Add , , "Testing"
.ListItems.Add , , "www.windmillsoftware.ca"
.ListItems.Add , , "www.chinamouldings.com"
.ListItems(1).Tag = .ListItems(1).Text
.ListItems(2).Tag = .ListItems(2).Text
.ColumnHeaders(1).Width = 4000
End With
End Sub
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
Debug.Print "Item Click"
End Sub
Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button = vbLeftButton) Then
ListView1.SelectedItem = ListView1.HitTest(X, Y)
ListView1.Drag vbBeginDrag
End If
End Sub
Private Sub WebBrowser1_DragDrop(Source As Control, X As Single, Y As Single)
If Not (Source.SelectedItem Is Nothing) Then
WebBrowser1.Navigate2 Source.SelectedItem.Tag
End If
End Sub
Whether it is a TreeView or ListView, the Node_Click and Item_Click events do not fire because of the Drag operation.
-
Mar 16th, 2006, 04:29 PM
#9
Thread Starter
Frenzied Member
Re: Click TreeView Node!
Bruce, I resolved this issue by adding the following code snippet:
VB Code:
Private Sub TreeView1_DragDrop(Source As Control, x As Single, y As Single)
wWeb.Navigate2 TreeView1.SelectedItem.Tag
End Sub
ARPAN
IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!
NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!
PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?
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
|