Why is the Visible property not correctly updated in a UserControl?
Sometimes my UserControl's Visible property does not get updated correctly. It happens at my app's boot time, in OnFontChanged, fired from inside InitializeComponent, probably because some other stuff has not been set up yet. I just can't find out what.
vScrollBar
is a UserControl and is开发者_高级运维 inside another UserControl. Apparently, this only happens when trying to set the value to true.
vScrollBar
already has its handle created, as a watch on IsHandleCreated says it's true.
Reading the Visible property gives you the actual visibility state of the control, not the 'intended' state. Which will always be false in the InitializeComponent() method, the form or control isn't visible yet until after the Load event runs. It will also be false if the container control isn't visible.
It may still show false if the Form has not loaded. Try setting it in the Form's OnLoad event.
精彩评论