Click here to Skip to main content
14,456,076 members
Rate this:
Please Sign up or sign in to vote.
See more: , +
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);
       }
Posted
Updated 18-Feb-20 6:55am
Comments
Gerry Schmitz 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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100