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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With