Click here to Skip to main content
15,886,362 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Form position Pin
Yulianto.25-Jul-05 16:07
Yulianto.25-Jul-05 16:07 
GeneralRe: Form position Pin
Dave Kreskowiak26-Jul-05 1:14
mveDave Kreskowiak26-Jul-05 1:14 
GeneralRe: Form position Pin
Yulianto.26-Jul-05 16:21
Yulianto.26-Jul-05 16:21 
GeneralRe: Form position Pin
Dave Kreskowiak27-Jul-05 1:28
mveDave Kreskowiak27-Jul-05 1:28 
GeneralRe: Form position Pin
Yulianto.27-Jul-05 16:10
Yulianto.27-Jul-05 16:10 
GeneralDir Structure from TreeView Pin
Brad Fackrell21-Jul-05 11:11
Brad Fackrell21-Jul-05 11:11 
GeneralRe: Dir Structure from TreeView Pin
Brad Fackrell21-Jul-05 12:28
Brad Fackrell21-Jul-05 12:28 
GeneralRe: Dir Structure from TreeView Pin
Brad Fackrell21-Jul-05 15:27
Brad Fackrell21-Jul-05 15:27 
I've made a little more progress but now I'm stuck on a drag/drop problem.

Does anybody know how to store the fullpath of a selected node during a drag and drop procedure?

Here is what I have tried (in every variation that I can think of):

Dim originalPosition As String

Private sub [tried several methods]

originalPosition = TreeView1.SelectedNode.FullPath [...tried multiple properties]

End sub


At the start of the drag/drop the original path is stored in originalPosition but after the drag/drop is complete, originalPosition has changed to the new full path.

I don’t understand how this is happening. Does anybody understand the drag/drop procedures enough to see what is going on?

Here is the code that I'm using for the drag/drop:
Public Sub TreeView1_ItemDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Handles TreeView1.ItemDrag
    DoDragDrop(e.Item, DragDropEffects.Move)
End Sub

Public Sub TreeView1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TreeView1.DragEnter

    If e.Data.GetDataPresent("System.Windows.Forms.TreeNode", True) Then
        e.Effect = DragDropEffects.Move
    Else
        e.Effect = DragDropEffects.None
    End If
End Sub

Private Sub TreeView1_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TreeView1.DragOver
    If e.Data.GetDataPresent("System.Windows.Forms.TreeNode", True) = False Then Exit Sub

    Dim selectedTreeview As TreeView = CType(sender, TreeView)
    Dim pt As Point = CType(sender, TreeView).PointToClient(New Point(e.X, e.Y))
    Dim targetNode As TreeNode = selectedTreeview.GetNodeAt(pt)

    If Not (selectedTreeview Is targetNode) Then
        selectedTreeview.SelectedNode = targetNode
        Dim dropNode As TreeNode = CType(e.Data.GetData("System.Windows.Forms.TreeNode"), TreeNode)
        Do Until targetNode Is Nothing
            If targetNode Is dropNode Then
                e.Effect = DragDropEffects.None
                Exit Sub
            End If
            targetNode = targetNode.Parent
        Loop
    End If

    e.Effect = DragDropEffects.Move
End Sub

Private Sub TreeView1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TreeView1.DragDrop
    If e.Data.GetDataPresent("System.Windows.Forms.TreeNode", _
          True) = False Then Exit Sub

    Dim selectedTreeview As TreeView = CType(sender, TreeView)
    Dim dropNode As TreeNode = _
          CType(e.Data.GetData("System.Windows.Forms.TreeNode"), _
          TreeNode)

    Dim targetNode As TreeNode = selectedTreeview.SelectedNode

    dropNode.Remove()
    If targetNode Is Nothing Then
        selectedTreeview.Nodes.Add(dropNode)
    Else
        targetNode.Nodes.Add(dropNode)
    End If
    dropNode.EnsureVisible()
    selectedTreeview.SelectedNode = dropNode
End Sub

GeneralRe: Dir Structure from TreeView Pin
[Marc]21-Jul-05 16:23
[Marc]21-Jul-05 16:23 
GeneralRe: Dir Structure from TreeView Pin
Brad Fackrell21-Jul-05 16:55
Brad Fackrell21-Jul-05 16:55 
QuestionHow do I set a global property for my project/namespace Pin
MaWeRic21-Jul-05 11:10
MaWeRic21-Jul-05 11:10 
AnswerRe: How do I set a global property for my project/namespace Pin
Dave Kreskowiak21-Jul-05 13:25
mveDave Kreskowiak21-Jul-05 13:25 
AnswerRe: How do I set a global property for my project/namespace Pin
Christian Graus21-Jul-05 13:47
protectorChristian Graus21-Jul-05 13:47 
GeneralRe: How do I set a global property for my project/namespace Pin
MaWeRic21-Jul-05 20:59
MaWeRic21-Jul-05 20:59 
GeneralRe: How do I set a global property for my project/namespace Pin
Dave Kreskowiak22-Jul-05 4:03
mveDave Kreskowiak22-Jul-05 4:03 
GeneralRe: How do I set a global property for my project/namespace Pin
ChewsHumans22-Jul-05 9:46
ChewsHumans22-Jul-05 9:46 
GeneralRe: How do I set a global property for my project/namespace Pin
Christian Graus22-Jul-05 11:43
protectorChristian Graus22-Jul-05 11:43 
GeneralRe: How do I set a global property for my project/namespace Pin
Dave Kreskowiak22-Jul-05 11:43
mveDave Kreskowiak22-Jul-05 11:43 
GeneralRe: How do I set a global property for my project/namespace Pin
MaWeRic22-Jul-05 21:33
MaWeRic22-Jul-05 21:33 
GeneralRe: How do I set a global property for my project/namespace Pin
Dave Kreskowiak23-Jul-05 5:30
mveDave Kreskowiak23-Jul-05 5:30 
GeneralRe: How do I set a global property for my project/namespace Pin
MaWeRic23-Jul-05 18:54
MaWeRic23-Jul-05 18:54 
GeneralRe: How do I set a global property for my project/namespace Pin
Dave Kreskowiak24-Jul-05 6:47
mveDave Kreskowiak24-Jul-05 6:47 
GeneralRe: How do I set a global property for my project/namespace Pin
MaWeRic24-Jul-05 8:07
MaWeRic24-Jul-05 8:07 
GeneralRe: How do I set a global property for my project/namespace Pin
Dave Kreskowiak25-Jul-05 0:29
mveDave Kreskowiak25-Jul-05 0:29 
GeneralRe: How do I set a global property for my project/namespace Pin
Christian Graus22-Jul-05 11:44
protectorChristian Graus22-Jul-05 11:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.