一个Win Form上有一个PictureBox,
从资源管理器里把一个图片文件拖拽到这个Form上,PictureBox就显示这个图片。
请问用C#如何实现,最好有详细代码,谢谢!

解决方案 »

  1.   

    http://www.mscourse.com/blog/u/Kayetyusha/archives/2007/160.html
      

  2.   

    给PictureBox添加如下的两个事件代码试试看,应该没有问题:protected override void OnLoad(EventArgs e)
    {
    base.OnLoad(e);
    this.pictureBox1.AllowDrop = true;//这句话直接写.
    }
    private void pictureBox1_DragOver(object sender, DragEventArgs e)
    {
    if ((e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link)
    {
    e.Effect = DragDropEffects.Link;
    }
    }private void pictureBox1_DragDrop(object sender, DragEventArgs e)
    {
    string[] items = (object)e.Data.GetData("FileNameW") as string[];
    if (items.Length == 1)
    {
    Image img = Image.FromFile(items[0]);
    this.pictureBox1.Image = img;
    }
    }
      

  3.   

    可以的呀,我直接用hbxtlhx(平民百姓) 的代码就成功了