Solved

Example

Posted on 2004-04-21
4
733 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

728 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