/// <override></override> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { if (context.PropertyDescriptor.PropertyType == typeof(string)) { string valueStr = string.IsNullOrEmpty((string)value) ? string.Empty : (string)value; using (TextEditorDialog stringEditor = new TextEditorDialog(valueStr)) { if (stringEditor.ShowDialog() == DialogResult.OK) value = stringEditor.ResultText; } } else if (context.PropertyDescriptor.PropertyType == typeof(string[])) { string[] valueArr = (value != null) ? (string[])value : new string[0]; using (TextEditorDialog stringEditor = new TextEditorDialog(valueArr)) { if (stringEditor.ShowDialog() == DialogResult.OK) value = stringEditor.ResultText; } } else if (context.PropertyDescriptor.PropertyType == typeof(IEnumerable<string>) || context.PropertyDescriptor.PropertyType == typeof(IList<string>) || context.PropertyDescriptor.PropertyType == typeof(ICollection<string>) || context.PropertyDescriptor.PropertyType == typeof(List<string>)) { IEnumerable<string> values = (value != null) ? (IEnumerable<string>)value : new string[0]; using (TextEditorDialog stringEditor = new TextEditorDialog(values)) { if (stringEditor.ShowDialog() == DialogResult.OK) value = new List<string>(stringEditor.Lines); } } } return value; }
/// <override></override> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { if (context.PropertyDescriptor.PropertyType == typeof(string)) { string valueStr = string.IsNullOrEmpty((string)value) ? string.Empty : (string)value; using (TextEditorDialog stringEditor = new TextEditorDialog(valueStr)) { if (stringEditor.ShowDialog() == DialogResult.OK) value = stringEditor.ResultText; } } else if (context.PropertyDescriptor.PropertyType == typeof(string[])) { string[] valueArr = (value != null) ? (string[])value : new string[0]; using (TextEditorDialog stringEditor = new TextEditorDialog(valueArr)) { if (stringEditor.ShowDialog() == DialogResult.OK) value = stringEditor.ResultText; } } else if (context.PropertyDescriptor.PropertyType == typeof(IEnumerable<string>) || context.PropertyDescriptor.PropertyType == typeof(IList<string>) || context.PropertyDescriptor.PropertyType == typeof(ICollection<string>) || context.PropertyDescriptor.PropertyType == typeof(List<string>)) { IEnumerable<string> values = (value != null) ? (IEnumerable<string>)value : new string[0]; using (TextEditorDialog stringEditor = new TextEditorDialog(values)) { if (stringEditor.ShowDialog() == DialogResult.OK) value = new List<string>(stringEditor.Lines); } } } return value; }