• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 653
  • Last Modified:

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?
R
0
r3nder
Asked:
r3nder
  • 4
  • 2
1 Solution
 
Mike TomlinsonMiddle 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"?
0
 
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;
            form.Controls.Add(asg);
            form.ShowDialog();

Open in new window

0
 
r3nderAuthor Commented:
got it this.parentform.height == 726;
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
r3nderAuthor Commented:
Thanks Idle
0
 
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.
0
 
r3nderAuthor Commented:
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now