winfrom之图片PictureBox显示滚动条

展开阅读全文

把一个PictureBox图片拖到另一个PictureBox里面显示

07-29

从桌面上可以拖动到PictureBoxrn从PictureBox1到PictureBox2却不行??rn什么问题呢?rnrn主要代码rnrnusing System;rnusing System.Collections.Generic;rnusing System.Drawing;rnusing System.Windows.Forms;rnrnnamespace Pic_Droprnrn /// rn /// Description of MainForm.rn /// rn public partial class MainForm : Formrn rn public MainForm()rn rn //rn // The InitializeComponent() call is required for Windows Forms designer support.rn //rn InitializeComponent();rn pictureBox1.AllowDrop=true;rn pictureBox2.AllowDrop=true;rn //rn // TODO: Add constructor code after the InitializeComponent() call.rn //rn rn rn void PictureBox1DragDrop(object sender, DragEventArgs e)rn rn string path =((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();rn pictureBox1.Image=new Bitmap(path);rn pictureBox1.Tag=path;rn rn rn void PictureBox1DragEnter(object sender, DragEventArgs e)rn rn if (e.Data.GetDataPresent(DataFormats.FileDrop)) rn e.Effect=DragDropEffects.Copy;rn rn elsern rn e.Effect=DragDropEffects.None;rn rn rn rn void PictureBox1MouseDown(object sender, MouseEventArgs e)rn rn if (pictureBox1.Image!=null) rn pictureBox1.DoDragDrop(pictureBox1.Image, DragDropEffects.Link|DragDropEffects.Copy);rn rn rn rn rn void PictureBox2DragDrop(object sender, DragEventArgs e)rn rn string path=((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();rn pictureBox2.Image=new Bitmap(path);rn rn rn void PictureBox2DragEnter(object sender, DragEventArgs e)rn rn if (e.Data.GetDataPresent(DataFormats.FileDrop)) rn e.Effect=DragDropEffects.Copy;rn rn rn rn void PictureBox2MouseDown(object sender, MouseEventArgs e)rn rn if (pictureBox2.Image!=null) rn pictureBox2.DoDragDrop(pictureBox2.Image, DragDropEffects.Copy);rn rn rn rn rn void Button1DragDrop(object sender, DragEventArgs e)rn rn string s=e.Data.GetData(DataFormats.FileDrop,true).ToString();rn rn rn rn void Button1DragEnter(object sender, DragEventArgs e)rn rn if (e.Data.GetDataPresent(DataFormats.FileDrop)) rn e.Effect=DragDropEffects.Copy;rn rn elsern rn e.Effect=DragDropEffects.None;rn rn rn rnrn 论坛

没有更多推荐了,返回首页