Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Example

Posted on 2004-04-21
4
Medium Priority
?
746 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 375 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

885 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