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 属性?
基础教程推荐
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- WPF 模态进度窗口 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
