drs
drs

Reputation: 133

Change Panel Size dynamically from right to left

I'm using this code to change panel size dynamically.

    timer1.Start();
    }
    private void timer1_Tick_1(object sender, EventArgs e)
    {
        int x;
        int y;
        x =panel2.Size.Width;
        y = panel2.Size.Height;
        panel2.Size = new Size(x + 10, y);
        if (x>150)
        {
            timer1.Stop();
        }
    }

The problem is that my panel is strating to change size and get bigger from left to right. But i need to place my panel some where left in my form. So i need to get bigger from RIGHT to LEFT.

Upvotes: 0

Views: 1080

Answers (1)

Mhd
Mhd

Reputation: 2978

You can't do that.

But as a workaround try to move the panel from Right to Left by changing panel location as well.

    private void timer1_Tick_1(object sender, EventArgs e)
    {
        int x = panel2.Size.Width;
        int y = panel2.Size.Height;
        panel2.Size = new Size(x + 10, y);
        panel2.Location = new Point(panel2.Location.X - 10, panel2.Location.Y);
        if (x>150)
        {
            timer1.Stop();
        }
    }

Upvotes: 2

Related Questions