?
Solved

vb.net Drag_Drop not firing

Posted on 2011-05-11
2
Medium Priority
?
410 Views
Last Modified: 2013-11-10
Hi.
I am trying to drag data from one DataGridView (to another  but the Drag_Drop event of the second control is not working even though I have set "Allow Drop" to true. This what I have done so far. STEP 4 is not firing at all. The first DataGridView is data bound and the second not

STEP 1
    Private Sub DataGridView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseDown

        Dim info As DataGridView.HitTestInfo = Me.DataGridView1.HitTest(e.X, e.Y)
        Dim row As DataGridViewRow = Me.DataGridView1.Rows(info.RowIndex)

        Me.DataGridView1.DoDragDrop(row, DragDropEffects.Copy)

    End Sub

STEP2
    Private Sub DataGridView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseDown

        Dim info As DataGridView.HitTestInfo = Me.DataGridView1.HitTest(e.X, e.Y)
        Dim row As DataGridViewRow = Me.DataGridView1.Rows(info.RowIndex)

        Me.DataGridView1.DoDragDrop(row, DragDropEffects.Copy)

    End Sub

STEP 3
 Private Sub DataGridView2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridView2.DragEnter

 e.Effect = DragDropEffects.All
End Sub

STEP 4
Private Sub DataGridView2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridView2.DragDrop

            Dim row As DataGridViewRow = TryCast(e.Data.GetData(GetType(DataGridViewRow)), DataGridViewRow)
.........etc etc
End Sub
0
Comment
Question by:Murray Brown
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 35736147
Try changing

e.Effect = DragDropEffects.All

to
e.Effect = DragDropEffects.Copy


Also, why step1 and step2 are same?
0
 

Author Closing Comment

by:Murray Brown
ID: 35736921
thanks
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

862 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