简体   繁体   English

Control.FindForm 和 ContainerControl.ParentForm 有什么区别

[英]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.FindFormContainerControl.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.

相关问题 Control.Select()和Control.Focus()之间有什么区别? - What's the difference between Control.Select() and Control.Focus()? Silverlight / WPF中的Control和ContentControl有什么区别? - What is the difference between Control and ContentControl in Silverlight/WPF? Control.BeginInvoke()和Dispatcher.BeginInvoke()有什么区别? - What is difference between Control.BeginInvoke() and Dispatcher.BeginInvoke()? .NET Applet和嵌入在IE中的ActiveX控件有什么区别 - What is the difference between a .NET Applet and ActiveX control embedded in IE 控件的边界与设置控件的X,Y,Width,Height有什么区别? - What is the difference between control's bounds and setting X,Y,Width,Height of a control? &gt; =和=&gt;之间有什么区别? - What is the difference between >= and =>? =和:=之间有什么区别 - What is the difference between = and := 文字控制模式之间的差异 - Difference between modes of literal control &lt;%#%&gt;和&lt;%=%&gt;之间有什么区别? - What's the difference between <%# %> and <%= %>? 可以从组成用户控件中访问ParentForm的Settings属性,以修改此类设置吗? - Can the ParentForm's Settings property be accessed from a constituent user control, in order to modify such a setting?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM