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

Posted on 2013-01-25
Last Modified: 2013-01-25
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?
Question by:r3nder
  • 4
  • 2
LVL 85

Accepted Solution

Mike Tomlinson earned 500 total points
ID: 38819907
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"?

Author Comment

ID: 38820092
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


Author Comment

ID: 38820115
got it this.parentform.height == 726;
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.


Author Closing Comment

ID: 38820118
Thanks Idle
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 38820233
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.

Author Comment

ID: 38821160
It is used for a usercontrol - I didnt want to open another window to update the form for just 1 select box

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Question! 4 36
compare between entities in entity framework 8 69
SQL Help 27 40
Store results in 3 20
This is about my first experience with programming Arduino.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now