[Editor(...)]
プロパティにを設定UITypeEditor
して、編集を行う を指定する必要があります。そのように(あなた自身のエディタで...)
using System;
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;
static class Program
{
static void Main()
{
Application.Run(new Form { Controls = { new PropertyGrid { SelectedObject = new Foo() } } });
}
}
class Foo
{
[Editor(typeof(StringEditor), typeof(UITypeEditor))]
public string Bar { get; set; }
}
class StringEditor : UITypeEditor
{
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
IWindowsFormsEditorService svc = (IWindowsFormsEditorService)
provider.GetService(typeof(IWindowsFormsEditorService));
if (svc != null)
{
svc.ShowDialog(new Form());
// update etc
}
return value;
}
}
必要に応じて動作する既存のプロパティを調べることで、既存のエディターを追跡できる場合があります。