is there a way to resize a usercontrol in a winform on a click event C#

I have a popup that I call and inside that popup is my  usercontrol with all my controls in it. I want to create an add section below it but still in the usercontrol. When they click add I want to "expand" the usercontrol and form to view those controls. Is it posible?
Who is Participating?
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
Sure.  Just change the size of the usercontrol and form.  The main issue is setting up the layout of the form so other controls gracefully shift when the size changes.  Depending on how the usercontrol is positioned and anchored/docked, you may be able to simply change the size of the form and the usercontrol will adjust accordingly.

How are you displaying the "popup"?
r3nderAuthor Commented:
AddToGrid asg = new AddToGrid();
            PopupForm form = new PopupForm();
            form.Text = "Add User";
            form.Height = asg.Size.Height + 30;
            form.Width = asg.Size.Width;

Open in new window

r3nderAuthor Commented:
got it this.parentform.height == 726;
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

r3nderAuthor Commented:
Thanks Idle
Mike TomlinsonMiddle School Assistant TeacherCommented:
Cool.  The only other thing I would mention is that some would recommend you not directly manipulate the parent form from the usercontrol in that manner.  Instead, you would make the usercontrol raise a custom event that requests the parent form resize itself.  If that particular usercontrol is very tightly integrated with the parent form, and doesn't get used in any other capacity, then it might not be worth the time.
r3nderAuthor Commented:
It is used for a usercontrol - I didnt want to open another window to update the form for just 1 select box
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.