Solved

Example

Posted on 2004-04-21
4
707 Views
Last Modified: 2012-05-04
Where can I find a good example of doing a drag drop from a datagrid to a treeview control. When I go to the DragDrop event of the treeveiw and try to get the node it always comes back as Nothing. Why is this? Here is the code.

 Private Sub tvMain_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles tvMain.DragDrop
        Dim n As Object = tvMain.GetNodeAt(e.X, e.Y)
        MsgBox(n.Text)
    End Sub

What am I doing wrong?
0
Comment
Question by:thenrich
4 Comments
 
LVL 9

Accepted Solution

by:
malharone earned 125 total points
Comment Utility
0
 
LVL 2

Expert Comment

by:navneet77
Comment Utility
Can you put the code you use when you start the drag process.
0
 
LVL 5

Author Comment

by:thenrich
Comment Utility
Private Sub C1TrueDBGrid1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles C1TrueDBGrid1.MouseDown
        If e.Button = MouseButtons.Right Then
            C1TrueDBGrid1.MoveRelative(0, C1TrueDBGrid1.RowContaining(e.Y))
        End If
        'Dim row, col As Integer
        'dragColumn = -1
        'If Me.C1TrueDBGrid1.CellContaining(e.X, e.Y, row, col) Then
        '    Me.C1TrueDBGrid1.MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.HighlightRow
        '    Me.C1TrueDBGrid1.Col = col
        '    Me.C1TrueDBGrid1.Bookmark = row
        '    dragColumn = col
        '    IsDrag = True
        'End If
        IsDrag = True
    End Sub
    Private Sub C1TrueDBGrid1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles C1TrueDBGrid1.MouseUp
        IsDrag = False
    End Sub

    Private Sub C1TrueDBGrid1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles C1TrueDBGrid1.MouseMove
        If dragColumn <> -1 And IsDrag Then
            Me.C1TrueDBGrid1.DoDragDrop("", DragDropEffects.Copy)
            IsDrag = False
        End If
    End Sub
0
 
LVL 4

Expert Comment

by:MajinLoki
Comment Utility
I have done drag and drop from a treeview to another form.
trvresults is my treeview.


Public Sub trvresults_ItemDrag(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Handles trvresults.ItemDrag
        Dim line As String
        Try
            If Not trvresults.SelectedNode.Parent Is Nothing Then
                line = trvresults.SelectedNode.Parent.Text & "        " & DirectCast(e.Item, System.Windows.Forms.TreeNode).Text
                DoDragDrop(line, Windows.Forms.DragDropEffects.Copy)
            End If
        Catch ex As Exception
            MsgBox("An error has occurred.")
            Report.reportError(ex)
        End Try
    End Sub

'***--- on the other page I have this

Private Sub Form1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter
        Try
            e.Effect = Windows.Forms.DragDropEffects.Copy
        Catch ex As Exception
            MsgBox("An error has occurred.")
            Report.reportError(ex)
        End Try
    End Sub

I know it's not exactly what you're looking for, but, maybe seeing it in reverse will help you get some ideas.  The trick I found was that when you start the drag drop on one side, it's easiest just to put all the data into a delimited string and then parse it out on the drop.  I really hope this helps you.

Majin Loki
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now