Hi all,

I've gotten the drag and drop to work in my listviewbox with some help. I'm not trying to get a file to show in the listviewbox when somebody selects the file from the open file dialog box I've made. I've been able to successfully show the file in the listviewbox when they select it, but I'm not sure how to get them into their respective columns. I want them to be able to select a file (.mp3) and have the song name under the 'Title' column and the file's location under the 'Location' column. I've gotten this to work if they drag and drop the file into the listbox, but not if they select it from the openfialdialog box. Here's my code:

private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string openFd = "";
            

            openFileDialog1.ShowDialog();

            if (openFileDialog1.ShowDialog() != DialogResult.Cancel)
            {
                openFd = openFileDialog1.FileName;
                listView1.Items.Add(openFd);
            }
            
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

Thanks.

It is not a good UI idea to let a user select something from a dialog and then let him click the Cancel button. Use the OK button instead.
Line 8 opens the dialog again, you opened it already in line 6.
So remove line 6.
Line 8 should read: if (openFileDialog1.ShowDialog() == DialogResult.OK)

This article has been dead for over six months. Start a new discussion instead.