private void toolStripButtonEditExpressions_Click(object sender, EventArgs e) { try { CollectionEditor.EditValue(this, this, "Expressions"); } catch (Exception ex) { Debug.WriteLine(ex); ExceptionDialog.ShowDialog(this, ex); } }
public static void EditValue(IWin32Window owner, object component, string propertyName) { PropertyDescriptor prop = TypeDescriptor.GetProperties(component)[propertyName]; if (prop == null) { throw new ArgumentException("propertyName"); } UITypeEditor editor = (UITypeEditor)prop.GetEditor(typeof(UITypeEditor)); CollectionEditor ctx = new CollectionEditor(owner, component, prop); if (editor != null && editor.GetEditStyle(ctx) == UITypeEditorEditStyle.Modal) { object value = prop.GetValue(component); value = editor.EditValue(ctx, ctx, value); if (!prop.IsReadOnly) { prop.SetValue(component, value); } } }