Solved

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

Posted on 2013-01-25
6
635 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is about my first experience with programming Arduino.
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 …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

746 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