Link to home
Start Free TrialLog in
Avatar of r3nder
r3nderFlag for United States of America

asked on

2 sliding panels

I have 2 sliding panels. When I click 1 button its panel slides in - disables the other button from allowing the second panel to slide. And if you click the same button again it slides the panel back off screen and re enables the second panel button.
What I would like to do is when I click on a button if the other panel is visible then hide it the show its own panel
        private void btnSent_Click(object sender, EventArgs e)
        {
            if (btnInTransit.Enabled == true)
            {
                btnInTransit.Enabled = false;
            }
            else
            {
                btnInTransit.Enabled = true;
            }
            btnSent.Enabled = false;
            if (PanelLocation == 1)
            {
                panel2.Visible = true;
                //if showing - hide
                for (int i = 0; i < panel2.Width; i++)
                {
                    panel2.Location = new Point(746 + i, panel2.Location.Y);
                }
                PanelLocation = 0;
                panel2.Visible = false;
            }
            else
            {
                //if hidding - show
                panel2.Visible = true;
                for (int i = 0; i < panel2.Width; i++)
                {
                    panel2.Location = new Point(1017 - i, panel2.Location.Y);
                    panel2.Invalidate();
                }
                PanelLocation = 1;
            }
            btnSent.Enabled = true;
        }
        private void btnInTransit_Click(object sender, EventArgs e)
        {
            if (btnSent.Enabled == true)
            {
                btnSent.Enabled = false;
            }
            else
            {
                btnSent.Enabled = true;
            }
            btnInTransit.Enabled = false;
            if (PanelLocation == 1)
            {
                panel1.Visible = true;
                //if showing - hide
                for (int i = 0; i < panel1.Width; i++)
                {
                    panel1.Location = new Point(746 + i, panel1.Location.Y);
                }
                PanelLocation = 0;
                panel1.Visible = false;
            }
            else
            {
                //if hidding - show
                panel1.Visible = true;
                for (int i = 0; i < panel1.Width; i++)
                {
                    panel1.Location = new Point(1017 - i, panel1.Location.Y);
                    panel1.Invalidate();
                }
                PanelLocation = 1;
            }
            btnInTransit.Enabled = true;
        }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of r3nder

ASKER

Awesome Mike thank you very much!