views:

23

answers:

2

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.

alt text

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.

+1  A: 

It may still show false if the Form has not loaded. Try setting it in the Form's OnLoad event.

adrift
Actual practical solution, Thx !
Gabriel
+2  A: 

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.

Hans Passant
"Very educational", thx (:
Gabriel