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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 86

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;
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.


Author Closing Comment

ID: 38820118
Thanks Idle
LVL 86

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
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…

695 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