The following code shows you dragging and dropping an image on form and setting that image the background of the form... using drag drop event of form. And also shows the path of dragged image.
private void Form1_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] list = (string[])e.Data.GetData(DataFormats.FileDrop,false);
Image img = Image.FromFile(list[0]);
this.BackgroundImage = img;
this.BackgroundImageLayout = ImageLayout.Center;
foreach (string file in list)
this.label1.Text += file + "\n";
}
}
0 comments:
Post a Comment