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
Solved

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

Posted on 2013-01-25
6
641 Views
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?
R
0
Comment
Question by:r3nder
  • 4
  • 2
6 Comments
 
LVL 85

Accepted Solution

by:
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"?
0
 
LVL 6

Author Comment

by:r3nder
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;
            form.Controls.Add(asg);
            form.ShowDialog();

Open in new window

0
 
LVL 6

Author Comment

by:r3nder
ID: 38820115
got it this.parentform.height == 726;
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 6

Author Closing Comment

by:r3nder
ID: 38820118
Thanks Idle
0
 
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.
0
 
LVL 6

Author Comment

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

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

860 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