简体   繁体   中英

UserControl inside Panel inside UserControl not working

I am having some trouble creating the template of my application :

I am making some dynamic parts of forms and I use a panel in which I include my User Control according to the choice of the user. The panel has the same size as the user control but it doesn't work at runtime. The panel in which the UC is included is inside another UC also.

I tried autoSize = true , fixed size and many things but I don't know why it goes like this. Any idea?

Some parts of my code to load the User Control :

 UC_panel.Controls.Clear();
 UC_ADDRESS uca = new UC_ADDRESS();


 uca.Dock = DockStyle.Fill;
 uca.AutoSize = true;
 UC_panel.Controls.Add(uca);

My UserControl for the address

At runtime it goes bigger

Since you set

uca.Dock = DockStyle.Fill;

and also

uca.AutoSize = true;

(which is redundant)

it is possible that some other container has its AutoScaleMode set to Font and its font size is bigger.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM