/// <summary> /// Factory method for creating the appropriate drop-down control based on the given property descriptor. /// If the property descriptor supports a UITypeEditor, a TypeEditorHost will be created with that editor. /// If not, and the TypeConverver attached to the PropertyDescriptor supports standard values, a /// TypeEditorHostListBox will be created with this TypeConverter. /// </summary> /// <param name="propertyDescriptor">A property descriptor describing the property being set</param> /// <param name="instance">The object instance being edited</param> /// <param name="editControlStyle">The type of control to show in the edit area.</param> /// <returns>A TypeEditorHost instance if the given property descriptor supports it, null otherwise.</returns> public static new TypeEditorHost Create(PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editControlStyle) { TypeEditorHost host = null; if (propertyDescriptor != null) { UITypeEditor editor = propertyDescriptor.GetEditor(typeof(UITypeEditor)) as UITypeEditor; if (editor != null) { return new OnScreenTypeEditorHost(editor, propertyDescriptor, instance, editControlStyle); } TypeConverter typeConverter = propertyDescriptor.Converter; if ((typeConverter != null) && typeConverter.GetStandardValuesSupported(null)) { host = new OnScreenTypeEditorHostListBox(typeConverter, propertyDescriptor, instance, editControlStyle); } } return host; }
/// <summary> /// Factory method for creating the appropriate drop-down control based on the given property descriptor. /// If the property descriptor supports a UITypeEditor, a TypeEditorHost will be created with that editor. /// If not, and the TypeConverver attached to the PropertyDescriptor supports standard values, a /// TypeEditorHostListBox will be created with this TypeConverter. /// </summary> /// <param name="propertyDescriptor">A property descriptor describing the property being set</param> /// <param name="instance">The object instance being edited</param> /// <param name="editControlStyle">The type of control to show in the edit area.</param> /// <returns>A TypeEditorHost instance if the given property descriptor supports it, null otherwise.</returns> public static new TypeEditorHost Create(PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editControlStyle) { TypeEditorHost host = null; if (propertyDescriptor != null) { UITypeEditor editor = propertyDescriptor.GetEditor(typeof(UITypeEditor)) as UITypeEditor; if (editor != null) { return(new OnScreenTypeEditorHost(editor, propertyDescriptor, instance, editControlStyle)); } TypeConverter typeConverter = propertyDescriptor.Converter; if ((typeConverter != null) && typeConverter.GetStandardValuesSupported(null)) { host = new OnScreenTypeEditorHostListBox(typeConverter, propertyDescriptor, instance, editControlStyle); } } return(host); }