public static object EditValue(ComponentDesigner designer, object objectToChange, string propName) { // Get PropertyDescriptor PropertyDescriptor descriptor = TypeDescriptor.GetProperties(objectToChange)[propName]; // Create a Context EditorServiceContext context = new EditorServiceContext(designer, descriptor); // Get Editor UITypeEditor editor = descriptor.GetEditor(typeof(UITypeEditor)) as UITypeEditor; // Get value to edit object value = descriptor.GetValue(objectToChange); // Edit value object newValue = editor.EditValue(context, context, value); if (newValue != value) { try { descriptor.SetValue(objectToChange, newValue); } catch (CheckoutException) { } } return(newValue); }
public void InvokeTemplateDialog() { PropertyDescriptor prop = TypeDescriptor.GetProperties(this.Component)["Workbook"]; UITypeEditor editor = prop.GetEditor(typeof(UITypeEditor)) as UITypeEditor; EditorServiceContext context = new EditorServiceContext(designer, prop); editor.EditValue(context, prop.GetValue(this.Component)); }