I have a checkedlistbox and I want to drag and drop only image extensions and not text files.
so how do I get it done.
I am able to drag and drop all file formats but I need only image files.
Here is my code:
Private Sub CheckedListBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles CheckedListBox1.DragDrop
Dim Files As String() = CType(e.Data.GetData(DataFormats.FileDrop), String())
For Each FileName As String In Files
CheckedListBox1.Items.Add(FileName, CheckState.Checked)
Thumbcontrol1.AddThumbnail(FileName)
Next
End Sub
Private Sub CheckedListBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles CheckedListBox1.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
Just check each file name’s extension.
You may want to add similar code to the DragEnter method to show
DragDropEffects.Noneif there are no picture files in the dragged file list.