Click here to Skip to main content
15,882,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want a panel of my form, to extend its size toward the left side when the form is maximized. I don't mean to anchor left, but the size of that panel to increase toward the left side. The anchor property puts the panel toward a specific side as we know. But i want it to increase its width toward the left side. I dont know how to achieve it.

What I have tried:

I opened the SizeChanged property of that panel, and then did the following code but that didn't work:
private void panel1_SizeChanged(object sender, EventArgs e)
           panel1.AutoSize = false;
           panel1.Size = new Size(700, 50);
Updated 18-Feb-20 5:55am
[no name] 14-Feb-20 23:44pm    
I expect you're current solution is recursing. If you're going to use "SizeChanged", you should use the Form's event.

1 solution

You would need to respond to the SizeChanged event of the Form (not the control), as Gerry said, and adjust the control's Location, not only its size. It seems odd that you wouldn't simply anchor it to the left, though, and then adjust its size. Or you could have all your controls anchored in a (fixed proportion) split container or table layout panel, which should resize everything accordingly.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900