Home Forums WPF controls Xceed DataGrid for WPF Drag and Drop operation.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #23666 |

    Hello,

    I’m trying to setup a drag and drop but it doesn’t work !

    Private Sub LeftGrid_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Input.MouseEventArgs) Handles LeftGrid.MouseMove
    If e.LeftButton Then

    Try
    Dim draggedfile As String

    draggedfile = LeftGrid.SelectedItem(0)

    Dim d As DataObject = New DataObject(DataFormats.Text, draggedfile)
    Dim fx As DragDropEffects = DragDrop.DoDragDrop(e.Source, d, DragDropEffects.All)

    Catch ex As Exception

    End Try

    End If

    End Sub

    I used to make it work under Windows.Forms but now i don’t …

    Do you have any idea ? 😀

    Thank you,

    Imported from legacy forums. Posted by Aybe (had 615 views)

    User (Old forums)
    Member
    Post count: 23064

    Alright, after went crazy, here’s the solution !

    For some reasons, even when retrieving one string from the Grid,
    it always passes it as an Array of Strings.

    Declare the result string as an array of strings and not only a single string,

    If e.LeftButton = MouseButtonState.Pressed Then

    Dim result(0) As String
    result(0) = LeftGrid.SelectedItem(6)

    Dim d As DataObject = New DataObject(DataFormats.FileDrop, result, True)
    Dim fx As DragDropEffects = DragDrop.DoDragDrop(LeftGrid, d, DragDropEffects.Copy)

    End If

    It’s a quick & dirty fix, but working 😀

    Imported from legacy forums. Posted by Aybe (had 2971 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.