Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Drag'n'drop

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

Drag'n'drop
Link Posted: 13-Feb-2006 02:30
In Drag'n'Drop demo ,when I drag node on itself, it disappears and demo is crashing
Link Posted: 13-Feb-2006 04:48
Thanks for your report, this code is corrected,
now replace the code of DragAccepted method in the DragDropfrm.vb sample with following:
[VB.Net]
    Private Function DragAccepted(ByVal data As IDataObject, ByVal grid As FlyGrid, ByVal x As Integer, ByVal y As Integer) As Boolean
      If (Not grid Is Nothing) Then
        Dim _targetNode As NodeBase = GetTargetNode(grid, x, y)

        If data.GetDataPresent(GetType(NodeBase)) Then
          Dim _node As NodeBase = CType(data.GetData(GetType(NodeBase)), NodeBase)          
          If _targetNode Is Nothing Or (Not (_targetNode.HasAsParent(_node)) Or Not (_node Is _targetNode)) Then
            Return True
          End If
        Else
          If data.GetDataPresent(GetType(NodeBase())) Then
            If Not _targetNode Is Nothing Then
              Dim nodes As NodeBase() = CType(data.GetData(GetType(NodeBase())), NodeBase())
              For i As Integer = 0 To nodes.Length - 1
                Dim _node As NodeBase = nodes(i)
                '//if dragged node is not parent of targetNode
                If (Not _targetNode Is Nothing) And (_targetNode.HasAsParent(_node) Or (_node Is _targetNode)) Then
                  Return False
                End If
              Next i
            End If
            Return True
          End If
        End If
      End If
      Return False
    End Function