Solved

Example

Posted on 2004-04-21
4
730 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
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 …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 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