/// <summary> /// Factory method for creating the appropriate drop-down control based on the given property descriptor /// </summary> /// <param name="propertyDescriptor"> /// Property descriptor used to create the drop-down. If the property descriptor supports a UITypeEditor, /// that will be used first. Otherwise, the type converter will be used. /// </param> /// <param name="instance">Instance of the object being edited.</param> /// <param name="editStyle"> /// In the case that a UITypeEditor is used, controls the style of drop-down created. This /// parameter is not used in the TypeConverter case. /// </param> /// <returns>A DropDownControl instance if the given property descriptor supports it, null otherwise.</returns> internal static TypeEditorHost CreateTypeEditorHost( PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editControlStyle) { TypeEditorHost dropDown = null; if (propertyDescriptor != null) { var uiTypeEditor = propertyDescriptor.GetEditor(typeof(UITypeEditor)) as UITypeEditor; if (uiTypeEditor != null) // UITypeEditor case { dropDown = new TreeGridDesignerInPlaceEditDropDown(uiTypeEditor, propertyDescriptor, instance, editControlStyle); } else { var converter = propertyDescriptor.Converter; if (converter != null && converter.GetStandardValuesSupported(null)) // converter case { dropDown = new TreeGridDesignerInPlaceEditCombo(converter, propertyDescriptor, instance, editControlStyle); } } } return(dropDown); }
/// <summary> /// Factory method for creating the appropriate drop-down control based on the given property descriptor /// </summary> /// <param name="propertyDescriptor"> /// Property descriptor used to create the drop-down. If the property descriptor supports a UITypeEditor, /// that will be used first. Otherwise, the type converter will be used. /// </param> /// <param name="instance">Instance of the object being edited.</param> /// <param name="editStyle"> /// In the case that a UITypeEditor is used, controls the style of drop-down created. This /// parameter is not used in the TypeConverter case. /// </param> /// <returns>A DropDownControl instance if the given property descriptor supports it, null otherwise.</returns> internal static TypeEditorHost CreateTypeEditorHost( PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editControlStyle) { TypeEditorHost dropDown = null; if (propertyDescriptor != null) { var uiTypeEditor = propertyDescriptor.GetEditor(typeof(UITypeEditor)) as UITypeEditor; if (uiTypeEditor != null) // UITypeEditor case { dropDown = new TreeGridDesignerInPlaceEditDropDown(uiTypeEditor, propertyDescriptor, instance, editControlStyle); } else { var converter = propertyDescriptor.Converter; if (converter != null && converter.GetStandardValuesSupported(null)) // converter case { dropDown = new TreeGridDesignerInPlaceEditCombo(converter, propertyDescriptor, instance, editControlStyle); } } } return dropDown; }