我有两个复选框。一个是我想要复制的文件夹列表。第二个是我要将文件夹复制到的位置列表。
问题是,我不知道如何单击复选列表框并移动到该位置。我所做的就是设置一个固定的位置,然后我就可以从一个文件夹复制到另一个文件夹。但我想选择核对表中的勾号,并从框1移到框2,而不是固定的位置和文件夹。
Private Sub moveContainerToLocation_Click(sender As System.Object, e As System.EventArgs) Handles moveContainerToLocation.Click
'To do
Try
Dim fileToCopy As String
Dim NewCopy As String
Dim fileSize As Long
' fileToCopy is folder i want to move
' NewCopy is the location what we choose to move the folder to
fileToCopy = "C:\folder test"
NewCopy = "C:\folder"
fileSize = GetFolderSize(fileToCopy)
' allow to overwrite
My.Computer.FileSystem.CopyDirectory(fileToCopy, NewCopy, True)
Timer1.Start()
moveContainerToLocation.Enabled = False
' the percentage of files transferred and use it into the progressbar
Dim counter =Directory.GetFiles(fileToCopy,"*",SearchOption.AllDirectories).Length
'Next
Catch ex As Exception
MessageBox.Show("ERROR")
End Try
End Sub‘’这是为了在我的checklistbox1中获取我的文件夹
Private Sub GetfolderButton_Click(sender As System.Object, e As System.EventArgs) Handles GetContainerButton.Click
For Each dra As String In Directory.GetDirectories("C:\folder test")
Container.Items.Add(dra)
Next
End Sub这是为了在我的checklistbox1中获取我的位置
Private Sub getLocationButton_Click(sender As System.Object, e As System.EventArgs) Handles getLocationButton.Click
For Each dr As String In Directory.GetDirectories("C:\folder")
Location.Items.Add(dr)
Next
End Sub发布于 2015-09-24 22:59:50
如果我正确理解您的问题,您是在问如何在CheckedListBox中获取选中的项,对吗?第一件事是,在CheckedListBox`中可能有多个选中项。所以你得不到一个答案。
If CheckedListBox1.CheckedItems.Count = 0 Then
MsgBox("Please select something")
Return
ElseIf CheckedListBox1.CheckedItems.Count > 1 Then
MsgBox("Please select only one item")
Return
End If
NewCopy = CheckedListBox1.CheckedItems(0)https://stackoverflow.com/questions/32750064
复制相似问题