按下按钮C#移动面板

时间:2013-12-12 21:48:36

标签: c# winforms event-handling panels

我对如何实现这一点感到困惑。我想按下按钮然后底部面板到顶部然后打开,如果这是有道理的。

这基本上就是我所拥有的 http://i.imgur.com/BzAeugE.png

我只有按钮点击的基本代码

private void CP_OneFbutton_Click(object sender, EventArgs e)
        {

        }

任何想法的人?

1 个答案:

答案 0 :(得分:2)

要执行此操作,您需要更改Panel的Location属性,如下所示:

panel1.Location = new Point(X,Y);

如果您不知道确切的坐标,那么您可以处理Form MouseMove事件(暂时)

 private void Form1_MouseMove(object sender, MouseEventArgs e)
    {
        label1.Text = e.X + "," + e.Y;
    }

将鼠标移动到要移动面板的位置并记下坐标,然后处理按钮单击事件并更改面板的位置

private void CP_OneFbutton_Click(object sender, EventArgs e)
    {
       panel1.Location = new Point(X,Y); // type your X and Y coordinates here
       panel1.Visible = true; // Display the panel
    }
相关问题