Moving panels on button press C#

7.6k views Asked by At

I'm confused as to how I can accomplish this. I want to press the buttons and then the bottom panels go to the top and then open, if that makes sense.

This is essentially what I have https://i.stack.imgur.com/adLoQ.png

And I only have the basic code for button clicks

private void CP_OneFbutton_Click(object sender, EventArgs e)
        {

        }

Any ideas guys?

1

There are 1 answers

0
Selman Genç On BEST ANSWER

To do this you need to change Panel's Location property like this:

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

If you don't know exact coordinates,then you can handle Form MouseMove event (temporarily)

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

Move mouse to the location where you want to panel move and note coordinates, then handle button click event and change panel's location

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
    }