Link to home
Start Free TrialLog in
Avatar of sherrick123
sherrick123

asked on

drag and drop from one list box to another

I was wanting to use the drag and drop option to add selected files from one listbox control to another.
i have the listbox set to multiselect.
I have it working now with a button the user has to press then of course i loop through all the selected items and add those to the other list box

Thanks
ASKER CERTIFIED SOLUTION
Avatar of iboutchkine
iboutchkine

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sherrick123
sherrick123

ASKER

it keep failing here is the code I took from yours.  The error is that it is out of range.  I get the erroro on the MouseDown event


 Private Sub lstDgnFiles_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstDgnFiles.MouseDown
        lstDgnFiles.DoDragDrop(lstDgnFiles.Items(lstDgnFiles.SelectedIndex()).ToString, DragDropEffects.Move)
    End Sub

    Private Sub lstMakePDF_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lstMakePDF.DragEnter
        If e.Data().GetDataPresent(DataFormats.FileDrop) Then
            e.Effect() = DragDropEffects.Move
        Else
            e.Effect() = DragDropEffects.None
        End If
    End Sub
Here is How I am populating the COPY FROM list box

  Private Sub cboFiles_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboFiles.SelectedIndexChanged
        Try
            Dim mySelDir As New DirectoryInfo(cboFiles.SelectedItem)
            Dim myFilename As FileInfo
            Dim myImageDir(1) As DirectoryInfo
            Dim myText As String

            myImageDir = mySelDir.GetDirectories("Images")

            lstDgnFiles.Items.Clear()
            lblOutPutDir.Text = myImageDir(0).FullName.ToString

            For Each myFilename In mySelDir.GetFiles("*.dgn")
                lstDgnFiles.Items.Add(myFilename)  'Add tostring to get out of the filename
            Next myFilename
        Catch ex As Exception
            MessageBox.Show("The process failed: {0}", ex.ToString())

        End Try