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.
I Think you're looking for this: https://stackoverflow.com/a/10871592/16165399
In your UserControl: this.Dock = DockStyle.Fill;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.