[英]How to make my panel move?
这是怎么回事,我有一个名为imagePanel1的imagePanel(您可以将其视为picturePanel)(我将其导入,因此不必制作滚动条:))
我在女巫的左侧有一个treeView,我可以拖动一个节点,并将其拖放到imagePanel上,在该位置我得到拖放的位置,然后在该位置上创建一个名为panel1的普通面板,所以我要做100次,所以最后我将有一个充满小面板的imagePanel ...现在是问题所在,当我单击imagePanel(面板所在的位置)时,我希望在MousePress上选择该面板,然后在mouseMove上移动,并最终在btnDelete上删除...
这是imagePanel的代码:// ******************************************** ***********************************
private void imagePanel1_DragDrop_1(object sender, DragEventArgs e)
{
Type testTip = new TreeNode().GetType();
YLScsImage.ImagePanel dropPicturePanel = (YLScsImage.ImagePanel)sender;
TreeNode movedNode;
_mouseDownSelectedWindow = Rectangle.Empty;
if (e.Data.GetDataPresent(testtype))
{
movedNode= (TreeNode)e.Data.GetData(testType);
dropPicturePanel.Tag = movedNode.Tag;
movedNode.ImageIndex = 1;
movedNode.SelectedImageIndex = 1;
movedNode.ForeColor = Color.Gray;
//**************************************
//HERE IS THE CODE FOR THE CREATED PANEL
Panel panel1 = new Panel();
Point point1 = this.PointToClient(new Point(e.X - 278, e.Y - 19)); //the imagePanel1 is on the form at the point 278,19
panel1.AllowDrop = true;
panel1.Location = point1;
panel1.BackgroundImage = iltest.Images[0]; //nvm
panel1.Height = 16;
panel1.Width = 16;
imagePanel1.Controls.Add(panel1); //am adding it to the imagePanel1
//saving the locations of each panel
string path = @"C:\Users\Cosic\Desktop\ICR\TABELA3_Paneli.txt"; // path to file
if (!File.Exists(path))
File.Create(path);
if (panelBr == 0)
System.IO.File.WriteAllBytes(path, new byte[0]); //brise ceo text iz fajla
TextWriter sw = new StreamWriter(path, true);
sw.WriteLine(e.X + "; " + e.Y + "; " + panel1.Width + "; " + panel1.Height + ";");
sw.Close();
//am done with saving
panelBr++;//nvm
}
}
告诉我是否需要更多代码...我得到了很多;)不好意思的英语不好,不是我想要的那么好...
我解决了这个问题,像这样:
panel1.MouseUp += new MouseEventHandler(panel1_MouseUp);
只需编写panel1.anyEventUWant + =和2次选项卡按钮....它会自动生成一个新函数,其中只有一条代码行
这是一个例子
void panel1_MouseUp (object sender, EventArgs e)
{
//throw new NotImplementedException();
}
U可以这样访问面板:((object)sender)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.