Why is the Visible property not correctly updated in a UserControl?(为什么在 UserControl 中没有正确更新 Visible 属性?)
问题描述
有时我的 UserControl 的 Visible 属性没有正确更新.它发生在我的应用程序启动时,在 OnFontChanged 中,从 InitializeComponent 内部触发,可能是因为尚未设置其他一些东西.我就是不知道是什么.
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.
推荐答案
如果Form还没有加载,可能还是会显示false.尝试在 Form 的 OnLoad 事件中设置它.
It may still show false if the Form has not loaded. Try setting it in the Form's OnLoad event.
这篇关于为什么在 UserControl 中没有正确更新 Visible 属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么在 UserControl 中没有正确更新 Visible 属性?


基础教程推荐
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01