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 属性?


- 如何用自己压缩一个 IEnumerable 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 输入按键事件处理程序 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01