C# 如何使我的面板移动?

C# 如何使我的面板移动?,c#,select,panel,move,picturebox,C#,Select,Panel,Move,Picturebox,怎么回事,我有一个imagePanel(你可以把它看作一个picturePanel) 名为imagePanel1(我导入了它,因此不必制作滚动条:) 我在左边有一个树状视图,我可以从witch拖动一个节点,把它放到imagePanel上,在那里我得到了放置的位置,在这个位置我创建了一个称为panel1的普通面板 所以我做了100次,最后我会有一个充满小面板的图像面板。。。 现在是问题所在,当我单击imagePanel(面板所在的位置)时 我想在MousePress上选择面板,然后在mouseMo

怎么回事,我有一个imagePanel(你可以把它看作一个picturePanel) 名为imagePanel1(我导入了它,因此不必制作滚动条:)

我在左边有一个树状视图,我可以从witch拖动一个节点,把它放到imagePanel上,在那里我得到了放置的位置,在这个位置我创建了一个称为panel1的普通面板 所以我做了100次,最后我会有一个充满小面板的图像面板。。。 现在是问题所在,当我单击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();     
} 

你可以这样访问面板:((对象)发送者)。

有没有办法附加GUI的屏幕截图?其他人可能会理解,但我很难在脑海中描绘你的GUI。标题是sry…但我无法发布图像,我需要10次声明才能做到这一点…以下是描述:左角是一个名为tView的树视图,右角是一个叫做imagePanel1的imagePanel,背景有一个change按钮,还有一个exit按钮,仅此而已