Solved

Example

Posted on 2004-04-21
4
722 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
ID: 10883354
0
 
LVL 2

Expert Comment

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

Author Comment

by:thenrich
ID: 10887875
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
ID: 10892827
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 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