Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
快速提问,如果 .NET 中的控件设置为不可见,它们是否有句柄(hWnd)?
马龙
如果 .Net 控件已经有句柄,则将其设置为Visible=false不会删除它。虽然可以看到没有句柄的 .Net 控件。句柄是在 WinForms 中按需创建的,在操作强制它存在之前,可能会看到缺少句柄。
Visible=false
当 Visible 属性变为真时创建句柄。如果它在表单构造函数中设置为 true,这是控件最常见的情况,这将在创建表单时发生,就在 Load 事件之前。再次将 Visible 设置为 false 不会破坏句柄。