Drag from listbox and drop in picturebox C#

Jul 8 2010 9:35 AM


I am working on a GUI where I have a listbox and a picturebox. The items in the listbox are image file paths. What I want to do is drag the file path from the listbox into the picturebox. When I run the code, nothing happens. Can someone help? Here is the code:

private void listbox1_MouseDown()
{
   string imagePath = (string) this.ListBox1.SelectedItem;
}

private void picBox1_MouseUp()
{
   if(e.Button == MouseButtons.Left)
      {
            picBox1.Load(imagePath);
      }
  imagePath = "";
}

Answers (3)