[英]What is the difference between Control.FindForm and ContainerControl.ParentForm
I'm wondering if there is any functional (or otherwise) difference between Control.FindForm
and ContainerControl.ParentForm
?我想知道
Control.FindForm
和ContainerControl.ParentForm
之间是否有任何功能(或其他)差异? I've been using .ParentForm
when creating my own user controls but would there be any reason .FindForm
would be a better choice?在创建自己的用户控件时,我一直在使用
.ParentForm
,但是有什么理由.FindForm
会是更好的选择吗? From what I can tell, they would always return the same form (ie. the form the user control is on, or null).据我所知,它们总是会返回相同的表单(即用户控件所在的表单或 null)。 Is
.ParentForm
just calling .FindForm
or is there a time where the two could be different (maybe with mdi windows)? .ParentForm
只是调用.FindForm
还是两者可能不同(可能使用 mdi 窗口)?
They are subtly different.它们有细微的不同。 ParentForm will return null when you call it on a toplevel Form since it has no parent.
当您在顶级表单上调用 ParentForm 时,它将返回 null,因为它没有父级。 FindForm() will not, it returns itself.
FindForm() 不会,它会返回自己。 And ParentForm makes a security demand, FindForm() does not.
ParentForm 提出了安全要求,而 FindForm() 没有。 They otherwise use the same internal implementation.
他们否则使用相同的内部实现。 Winforms itself doesn't use ParentForm at all, I would ignore it.
Winforms 本身根本不使用 ParentForm,我会忽略它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.