C# winform 如何实现将PictureBox控件拖动到任意的Panel控件中。

.Net技术 码拜 9年前 (2015-05-11) 2024次浏览 0个评论
 

在C# winform中,有一个form窗体,在form窗体中包函四个Panel控件(panel1、panel2、panel3、panel4)以及多个PictureBox控件。

请问,如何实现将PictureBox控件手动拖动到任意一个Panel控件中,且充满当前拖动到目标的Panel控件中显示。
最好提供相关的源码或参考资料,谢谢。

3分
http://bbs.csdn.net/topics/390167835
http://www.cnblogs.com/Joetao/articles/3111844.html

外事不决问谷歌

2分
有拖放事件,,,
5分
AllowDrop = true;

DragEnter += delegate(object sender, DragEventArgs e)
            {
                e.Effect = DragDropEffects.Move;
            };

DragDrop += delegate(object sender, DragEventArgs e)
            {
                ((Control)e.Data.GetData(typeof(PictureBox))) // 这里是传过来的控件
                //下面写添加代码
             
            };

MouseMove += delegate(object sender, MouseEventArgs e)
                {
               
                        PictureBox lb = (PictureBox)sender;
                        lb.DoDragDrop(lb, DragDropEffects.Move);

                };

大概流程是酱紫。

谢谢楼上的回复,还有其他的方法吗?
10分
http://blog.csdn.net/starfd/article/details/44861047
这个是panel拖panel的,可以做参考

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明C# winform 如何实现将PictureBox控件拖动到任意的Panel控件中。
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!