为什么未在UserControl中正确更新Visible属性? [英] Why is the Visible property not correctly updated in a UserControl?

查看:91
本文介绍了为什么未在UserControl中正确更新Visible属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,我的UserControl的Visible属性无法正确更新.它发生在我的应用程序启动时,从InitializeComponent内部触发的OnFontChanged中,这可能是因为尚未设置一些其他内容.我就是找不到.

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是一个UserControl,位于另一个UserControl中.显然,这仅在尝试将值设置为true时发生. vScrollBar已经创建了它的句柄,因为IsHandleCreated上的手表说的是真的.

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.

推荐答案

如果尚未加载表单,它仍可能显示false.尝试在窗体的OnLoad事件中进行设置.

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

这篇关于为什么未在UserControl中正确更新Visible属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆