Using WinForms I encode a Component user control where I would like it to be able to display the designer editor form, where I could see a list of all the control names in the form where the component is located.
I got the basic mechanics of the user component element and the support of the designer editor. This is not my question.
Let's say I have a form where in the IDE I put the component in the component tray and several other controls on the form. Now I call the constructor editor for the component, and I show a list of the names of the controls.
Here is the code snippet:
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 get only the type name!
There must be something obvious ...;)
Stécy source share