Why is the Visible property not correctly updated in a UserControl?

前端 未结 2 2054
梦如初夏
梦如初夏 2020-12-19 13:53

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, prob

相关标签:
2条回答
  • 2020-12-19 14:17

    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.

    0 讨论(0)
  • 2020-12-19 14:32

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

    0 讨论(0)
提交回复
热议问题