开发者

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? I've been using .ParentForm when creating my own user controls but would there be any reason .FindForm would be a better 开发者_如何学编程choice? From what I can tell, they would always return the same form (ie. the form the user control is on, or null). Is .ParentForm just calling .FindForm or is there a time where the two could be different (maybe with mdi windows)?


They are subtly different. ParentForm will return null when you call it on a toplevel Form since it has no parent. FindForm() will not, it returns itself. And ParentForm makes a security demand, FindForm() does not. They otherwise use the same internal implementation. Winforms itself doesn't use ParentForm at all, I would ignore it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜