vb.net - Determine if DataGridView Row being Dragged over Treeview -
how determine if item i'm dragging datagridview treeview datagridview row?
i have treeview has ability drag , drop itself, want put check in treeview dragover check see if treenode or datagridview row.
i know can check if treeview node doing..
if e.data.getdatapresent("system.windows.forms.treenode", true) = false exit sub
but tried doing..
if e.data.getdatapresent("system.windows.forms.datagridviewrow", true) = false exit sub
but isn't working me. i'm not sure i'm doing wrong?
private sub datagridview1_mousedown(byval sender object, byval e mouseeventargs) handles datagridview1.mousedown if datagridview1.currentrow nothing exit sub if e.button = mousebuttons.left , datagridview1.currentcell.columnindex >= 0 drageditemtext = datagridview1.rows(datagridview1.currentcell.rowindex).cells(0).value.tostring drageditemext = datagridview1.rows(datagridview1.currentcell.rowindex).cells(1).value.tostring drageditemrowindex = datagridview1.currentcell.rowindex datagridview1.dodragdrop(drageditemtext, dragdropeffects.copy) end sub public sub treeview1_dragenter(byval sender system.object, byval e system.windows.forms.drageventargs) e.effect = dragdropeffects.copy if e.data.getdatapresent("system.windows.forms.datagridviewrow", true) console.writeline("datagridviewrow") e.effect = dragdropeffects.move exit sub end if 'see if there treenode being dragged if e.data.getdatapresent("system.windows.forms.treenode", true) 'treenode found allow move effect e.effect = dragdropeffects.move else 'no treenode found, prevent move e.effect = dragdropeffects.none end if end sub
you sending text, not row.
try this:
datagridview1.dodragdrop(datagridview1.currentrow, dragdropeffects.copy)
Comments
Post a Comment