If you are designing in a WinForms component, which is anything that derives from Control at some point (Forms, UserControls, panels, etc), then you can use the following code:
The above will throw an exception if Site is not set (in most cases it is, ie the control is in a container control). However:
Will return false if there is no container. This is an alternative (and much neater) method, but may give incorrect results in certain (rare) circumstances.
6D Systems LLC
I studied Software Engineering at Milwaukee School of Engineering for 2 years before switching to Management of Information Systems for a more business oriented approach. I've been developing software since the age of 14, and have waded through languages such as QBasic, TrueBasic, C, C++, Java, VB6, VB.NET, C#, etc. I've been developing professionally since 2002 in .NET.