2014-12-16 3 views
0

나는 여러 대의 ListView 홀더를 보관하기 위해 TabControl을 사용하여 매일 직장에서 사용하는 파일을위한 저장소를 만들고 있습니다. Listview.ItemDrag files handling

Dim fileFullPath As String 
Dim mySelectedItem As ListViewItem = lvTools.SelectedItems(0) 
Dim dropList As New StringCollection 
'DataObject requires a StringCollection 
Dim DragPaths As New DataObject() 

fileFullPath = Path.Combine(ToolsDirectory, mySelectedItem.Tag) 

Try 
    'The fileInfo is created because it lets the DoDragDrop be faster 
    Dim fileToDrop As New FileInfo(fileFullPath) 
    dropList.Add(fileFullPath) 

    DragPaths.SetFileDropList(dropList) 
    DoDragDrop(DragPaths, DragDropEffects.All) 
Catch FNTE As FileNotFoundException 
    MsgBox("File could not be found: " & fileFullPath) 
Catch ex As Exception 
    MsgBox(ex.ToString) 
End Try 

는 내가의 내용을 복사 할 수 방법에 대해 어떤 생각을 가지고 있습니까 : 나는리스트 뷰 내부에서 ListView.ItemDrag 이벤트 핸들러 내부에 다음 코드를 사용하여 내 프로그램 외부로 드래그 앤 드롭 기능을 만들고 관리해야 파일을 복사하는 대신 .txt 파일을?

If File.Exists(fileFullPath) Then 
    Using tr As TextReader = New StreamReader(fileFullPath) 
     Dim fileToDrop As New FileInfo(fileFullPath) 
     dropList.Add(fileFullPath) 

     DragPaths.SetFileDropList(dropList) 
     Dim filecontent As String = tr.ReadToEnd() 
     DoDragDrop(filecontent, DragDropEffects.Copy) 
    End Using 
End If 
:

답변

0

나는 솔루션에 대한 다음 코드를 참조하십시오,이 알아 낸