-
ListView Drag and Drop Com Error
When trying to do a drag and drop from a list view control to the desktop I get the following error:
This is file drop operation to the desktop.
System.Runtime.InteropServices.COMException crossed a native/managed boundary
Message=Invalid FORMATETC structure (Exception from HRESULT: 0x80040064 (DV_E_FORMATETC))
Source=mscorlib
ErrorCode=-2147221404
StackTrace:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Windows.Forms.DataObject.System.Runtime.InteropServices.ComTypes.IDataObject.GetDat aHere(FORMATETC& formatetc, STGMEDIUM& medium)
at System.Windows.Forms.DataObject.System.Runtime.InteropServices.ComTypes.IDataObject.GetDat a(FORMATETC& formatetc, STGMEDIUM& medium)
InnerException:
Here is some sample code:
Dim myItem As ListViewItem
'Create an array of strings.
Dim myItems(lvwLocalDir.SelectedItems.Count - 1) As String
Dim i As Integer = 0
Dim path1 As String = IO.Directory.GetCurrentDirectory
If path1.EndsWith("\") = False Then
path1 += "\"
End If
Dim pathReset As String = path1
'Loop though the SelectedItems collection of the ListView control.
For Each myItem In lvwLocalDir.SelectedItems
'Add the Text of the ListViewItem to the array.
path1 += myItem.Text
myItems(i) = path1
path1 = pathReset
'myItems(i) = myItem.Text
i = i + 1
Next
' Creates a data object.
Dim myDataObject As New DataObject()
' Adds the component to the data object.
myDataObject.SetData(DataFormats.FileDrop, myItems)
'DoDragDrop begins the drag-and-drop operation.
'The data to be dragged is the array of strings.
lvwLocalDir.DoDragDrop(myItems, DragDropEffects.Copy)
'Catch ex As Exception
' Stop
'End Try
Dim j As ListViewItem
For Each j In lvwLocalDir.SelectedItems
'Remove the ListViewItem from the ListView control.
lvwLocalDir.Items.Remove(j)
Next
Do you have any Ideals of how I can fix this problem?
Thanks,
QWERT
Blue Wave Software
Similar Threads
-
Replies: 3
Last Post: 07-18-2012, 01:45 PM
-
Replies: 1
Last Post: 12-22-2008, 09:26 AM
-
By Jim Pragit in forum .NET
Replies: 5
Last Post: 08-10-2005, 07:16 AM
-
By andy.net in forum .NET
Replies: 2
Last Post: 07-23-2002, 08:26 PM
-
Replies: 0
Last Post: 03-13-2002, 05:03 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks