CASorter
asked on
drag and drop from a datagridview to a list box
i had this working, and then it stopped ...
not sure what i did.
object is to grab a row from a datagridview and put it into whichever list box i end up over.
DGV has 3 columns, i am only putting column 1 and 0 in the list box.
now if i try and grab a row and move it.. the datagridview1_mousedown fires but when i move the mouse, i get a circle with a slash and when i move it over the lists box the dragenter doesnt fire
when i let go of the mosue the circle slash dissappears
i have allow drop set to true for all the listboxes.
Private Sub DataGridView1_MouseDown(By Val sender As Object, ByVal e As System.Windows.Forms.Mouse EventArgs) Handles DataGridView1.MouseDown
DataGridView1.DoDragDrop(D ataGridVie w1.Selecte dRows, DragDropEffects.Move)
End Sub
Private Sub ListBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragE ventArgs) Handles ListBox1.DragDrop
Dim rows As DataGridViewSelectedRowCol lection = DirectCast(e.Data.GetData( GetType(Da taGridView SelectedRo wCollectio n)), DataGridViewSelectedRowCol lection)
Dim Row_String As String
For Each row As DataGridViewRow In rows
Row_String = RTrim(LTrim(row.Cells(1).V alue.ToStr ing)) + " " + row.Cells(0).Value
ListBox1.Items.Add(Row_Str ing)
DataGridView1.Rows.Remove( row)
Next
End Sub
Private Sub ListBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragE ventArgs)
If (e.Data.GetDataPresent(Get Type(DataG ridViewSel ectedRowCo llection)) ) Then
e.Effect = DragDropEffects.Move
End If
End Sub
Private Sub ListBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragE ventArgs)
Dim rows As DataGridViewSelectedRowCol lection = DirectCast(e.Data.GetData( GetType(Da taGridView SelectedRo wCollectio n)), DataGridViewSelectedRowCol lection)
Dim Row_String As String
For Each row As DataGridViewRow In rows
Row_String = RTrim(LTrim(row.Cells(1).V alue.ToStr ing)) + " " + row.Cells(0).Value
ListBox2.Items.Add(Row_Str ing)
DataGridView1.Rows.Remove( row)
Next
End Sub
Private Sub ListBox2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragE ventArgs)
If (e.Data.GetDataPresent(Get Type(DataG ridViewSel ectedRowCo llection)) ) Then
e.Effect = DragDropEffects.Move
End If
End Sub
not sure what i did.
object is to grab a row from a datagridview and put it into whichever list box i end up over.
DGV has 3 columns, i am only putting column 1 and 0 in the list box.
now if i try and grab a row and move it.. the datagridview1_mousedown fires but when i move the mouse, i get a circle with a slash and when i move it over the lists box the dragenter doesnt fire
when i let go of the mosue the circle slash dissappears
i have allow drop set to true for all the listboxes.
Private Sub DataGridView1_MouseDown(By
DataGridView1.DoDragDrop(D
End Sub
Private Sub ListBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragE
Dim rows As DataGridViewSelectedRowCol
Dim Row_String As String
For Each row As DataGridViewRow In rows
Row_String = RTrim(LTrim(row.Cells(1).V
ListBox1.Items.Add(Row_Str
DataGridView1.Rows.Remove(
Next
End Sub
Private Sub ListBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragE
If (e.Data.GetDataPresent(Get
e.Effect = DragDropEffects.Move
End If
End Sub
Private Sub ListBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragE
Dim rows As DataGridViewSelectedRowCol
Dim Row_String As String
For Each row As DataGridViewRow In rows
Row_String = RTrim(LTrim(row.Cells(1).V
ListBox2.Items.Add(Row_Str
DataGridView1.Rows.Remove(
Next
End Sub
Private Sub ListBox2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragE
If (e.Data.GetDataPresent(Get
e.Effect = DragDropEffects.Move
End If
End Sub
First, I suggest on DragEnter, do a messagebox of the type data to be sure that it is what you think it is.
ASKER
I have a stop in the dragenter.... it does not hit it
the circle with the line appears right after I start to move the mouse (after I left click), and stays until I let go of the mouse button. but no dragenter events fire on any of the listboxes.
the circle with the line appears right after I start to move the mouse (after I left click), and stays until I let go of the mouse button. but no dragenter events fire on any of the listboxes.
Instead of DataGridView1_MouseDown, move the code to MouseMove
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
have been withouth power for 3 days.. will try this on monday
ASKER
that worked...
thanks
thanks