Hi there,

I need to determine if an arbitrary control appears on a form's design tray
or the actual form itself (or other parent container). Is the following
check reliable or is there an official way (or something cleaner). Thanks.

public static bool IsTrayControl(Control control)
{
return (TypeDescriptor.GetProperties(control)["TrayLocation"] != null);
}

Re: Detecting a tray control by Mattias

Mattias
Fri Apr 20 14:21:21 CDT 2007

>I need to determine if an arbitrary control appears on a form's design tray
>or the actual form itself (or other parent container). Is the following
>check reliable or is there an official way (or something cleaner). Thanks.

Don't all controls show up on the Form? I thought only things derived
from Component but not from Control end up in the tray area.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Re: Detecting a tray control by Larry

Larry
Sat Apr 21 10:21:21 CDT 2007

> Don't all controls show up on the Form? I thought only things derived
> from Component but not from Control end up in the tray area.

Well, everything in the designer derives from "IComponent" AFAIK and
"Component" is just a common implementation of this, is it not. In any case,
take a look at the "ToolStrip" class for example. It's a "Control"
derivative but it's also in the tray area.