これが私の現在のドラッグアンドドロップコードです。メール(添付ファイルではない)から画像をドラッグしています。カーソルはうまく変化しますが、ドロップするとエラーになります
Unable to cast object of type 'System.IO.MemoryStream' to type 'System.Drawing.Imaging.Metafile[]'.
私は何を間違っていますか?MetafilePict は使用するデータ形式が間違っていますか?
Private Sub ImageViewer_DragDrop(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.DragEventArgs) _
Handles MyBase.DragDrop
If (e.Data.GetDataPresent(DataFormats.MetafilePict, False)) Then
Try
For Each path As Metafile In CType(e.Data.GetData(DataFormats.MetafilePict), Metafile())
'Do stuff with data
Next
Catch ex As Exception
MessageBox.Show("Error Doing Drag/Drop")
End Try
End If
End Sub
Private Sub ImageViewer_DragEnter(ByVal sender As System.Object, ByVal _
e As System.Windows.Forms.DragEventArgs) _
Handles MyBase.DragEnter
If (e.Data.GetDataPresent(DataFormats.MetafilePict, True)) Then
e.Effect = DragDropEffects.Copy
End If
End Sub