Detecting a tray control

  • Thread starter Thread starter Larry Smith
  • Start date Start date
L

Larry Smith

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);
}
 
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
 
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.
 
Back
Top