how will i know the size of user control?
开发者_高级运维How will I know the size of user control at run time?
I have a form, and I wanted to host my usercontrol on that form, and I wanted to know my user control size at run time to fix my webform size according to my user control size, so that scroll should not appear while opening the form.
How can I do that?
(actually there are multiple Usercontrols, and I am hosting a user control at run time according to a condition.)
You can expose a .Size
property that would contain the height/width of user control. While rendering the control, you read the .Size
and process accordingly.
Are you looking for ActualWidth / ActualHeight
?
Also you should be able to set the ScrollBar
policy to Auto
so that it will only appear if needed.
精彩评论