using DevExpress.XtraRichEdit; using System; using System.Collections.Generic; using System.Drawing.Design; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Windows.Forms.Design; namespace UI.Framework.Entitys { /// /// PropertyGridMutiText 的摘要说明。 /// public class PropertyGridRichText : PropertyGridEditStyle { public PropertyGridRichText() { RichEditControl box = new RichEditControl(); box.ActiveViewType = DevExpress.XtraRichEdit.RichEditViewType.Simple; Control = box; } public override string GetValue() { return Control.Text; } public override void SetValue(object value) { Control.Text = value as string; } } public abstract class PropertyGridEditStyle : UITypeEditor { protected UITypeEditorEditStyle UITypeEditorEditStyle = UITypeEditorEditStyle.DropDown; protected Control Control = null; public abstract string GetValue(); public abstract void SetValue(object value); public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) { return UITypeEditorEditStyle; } public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { try { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { SetValue(value); if(UITypeEditorEditStyle == UITypeEditorEditStyle.DropDown) edSvc.DropDownControl(Control); return GetValue(); } } catch (Exception ) { return value; } return value; } } }