Using WinForms I am coding a Component user control where I would like it to be able to display a designer editor form where I could see the list of all the controls names on the form where the component is located.
I got the basic mechanics of the component user control and the support of the designer editor. My question is not about that.
Let's say I have a form where, in the IDE, I place the component in the component tray and several other controls on the form. Now, I invoke the designer editor for the component and I display the list of controls names.
Here's a snippet of code:
internal class MyComponentEditor : UITypeEditor
{
public override object EditValue
(
ITypeDescriptorContext context,
IServiceProvider provider, object value
)
{
var instance = context.Instance as MyComponent;
var container = instance.Container;
var controls = container.Components.Cast<Control>;
var names = controls.Select (x => x.Name);
}
}
Here, the names variable should contain the names of all the controls but I only get the type name!
Must be something obvious... ;)