-1

I'm having a problem using user controls with panels. When I load user control into the panel with the code:

 panel3.Controls.Add(new userControl1());

it loads with the size of my initial usercontrol1 size. Actually, I have already made my form to maximize with this code.

 this.MaximizedBounds = Screen.FromHandle(this.Handle).WorkingArea;
 this.WindowState = FormWindowState.Maximized;

I also tried all the solutions I was able to find. 1- I tried to Dock Fill with the panel, user control, Anchoring to all sides. 2- Also did AutoSize = True for user control and panel. Nothing works at this point.

Actually, when I first time did load user control into the panel it loaded okay in my original project. then I don't know what happened. The image uploaded below is captured from the scratch new project. So, be sure it's not a problem with my original project either.

Sample Problem Project

SH7
  • 732
  • 7
  • 20

1 Answers1

0

I Think you're looking for this : https://stackoverflow.com/a/10871592/16165399

In your UserControl : this.Dock = DockStyle.Fill;

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 22 '21 at 14:58