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.
It may still show false if the Form has not loaded. Try setting it in the Form's OnLoad event.
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.
来源:https://stackoverflow.com/questions/3780140/why-is-the-visible-property-not-correctly-updated-in-a-usercontrol