Discussion:
Detecting a tray control
(too old to reply)
Larry Smith
2007-04-20 16:52:02 UTC
Permalink
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);
}
Mattias Sjögren
2007-04-20 19:21:21 UTC
Permalink
Post by Larry Smith
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.
Larry Smith
2007-04-21 15:21:21 UTC
Permalink
Post by Mattias Sjögren
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.

Loading...