Yes you have it. Here is the code.
GridView Event code
'//Get the gridview for the gvGenericLibrary
Dim gv As DevExpress.XtraGrid.Views.Grid.GridView = TryCast(Me.gvGenericLibrary.MainView, DevExpress.XtraGrid.Views.Grid.GridView)
'//Ensure that the user is clicking on a datarow
If gv.FocusedRowHandle < 0 Then Exit Sub
Try
'//Update user form
StartWorking("Building Component")
'// Fetch the information from the library and create respective node
Dim _n As FlowChartItems.NodeBase = ARSFactory.GetNode(gv.GetDataRow(gv.FocusedRowHandle).Item("ID").ToString)
DoDragDrop(New NodeDragItem(_n.Copy), DragDropEffects.Copy)
Catch ex As Exception
My.Application.Log.WriteException(ex)
MessageBox.Show(ex.Message, "Error building component", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
'// change form to non-working state
StopWorking()
End Try
List Box handler
Private Sub ilbComponents_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ilbComponents.MouseDown
DoDragDrop(New NodeDragItem(Me.ilbComponents.SelectedIndex), DragDropEffects.Copy)
End Sub
Drop Event on Flowchart
Private Sub fcMain_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles fcMain.DragDrop
Try
_parent.StartWorking("Creating Node")
If e.Data.GetDataPresent(NodeDragItem._GetType()) Then
Dim sdi As NodeDragItem = DirectCast(e.Data.GetData(NodeDragItem._GetType()), NodeDragItem)
If sdi.Index >= 0 And sdi.Index < NodeTemplates.Nodes.Count Then
Dim p As Point = fcMain.PointToClient(New Point(e.X, e.Y))
Dim pt As PointF = fcMain.ClientToDoc(New Point(p.X, p.Y))
'test to see if the nodedragitem is storing an ARS node to copy
Dim _n As FlowChartItems.NodeBase
If Not sdi.Node Is Nothing Then
_n = sdi.Node
Else
_n = ARSFactory.GetNewNode(NodeTemplates.Nodes(sdi.Index + 1).GetType.Name.ToString)
End If
DrawNode(_n, pt.X, pt.Y)
End If
End If
Catch ex As Exception
My.Application.Log.WriteException(ex)
MessageBox.Show("Error creating node", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
_parent.StopWorking()
End Try
End Sub
The drawnode event just creates an instance of the node in the workspace. No Drag or Drop events are ffired here.
DragOver Event
Private Sub fcMain_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles fcMain.DragOver
If e.Data.GetDataPresent(NodeDragItem._GetType()) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub