简体   繁体   English

在拖放中交换图片框

[英]swap picturebox in drag and drop

Hi I've been trying to do a swap between two PictureBoxes with drag and drop, the code I'm using to do the drag and drop is C# Drag and Drop from one Picture box into Another 嗨,我一直在尝试通过拖放操作在两个PictureBox之间进行交换,我用来进行拖放的代码是C#从一个图片框到另一个的拖放

But I have 9 pictureboxes and i need the swap to be dynamic, cant manage to get the name of the picturebox from where the image is coming so i can do the swap, would love some help on the subject. 但是我有9个图片框,我需要动态地进行交换,无法设法从即将到来的图片中获取图片框的名称,因此我可以进行交换,希望在此方面有所帮助。

A global variable will do your thing like this; 全局变量将完成您的工作;

PictureBox from;

when a drag starts from picturebox1 ; 当从picturebox1开始拖动时;

From = picturebox1;

when a drag starts from picturebox2 ; 当拖动从picturebox2开始时;

From = picturebox2;

when DragDrop a picturebox the from variable will be the images source 当拖放图片框时, from变量将成为图像源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM