0

ジェネリック型のすべてのインスタンスに対してカスタム UI エディターを指定するにはどうすればよいですか? タイプは、私が所有していない別のアセンブリで定義されています。


これは、 https://stackoverflow.com/a/849778/284795に触発されて試したものですが、効果はありませんでした(古いエディターは残っています)。ここでは、ジェネリック型List<>とカスタム エディターDateTimeeditor- ナンセンスですが、これは単なる例です。

TypeDescriptor.AddAttributes(typeof(List<>),new EditorAttribute(typeof(System.ComponentModel.Design.DateTimeEditor),typeof(UITypeEditor)));
TypeDescriptor.GetEditor(new List<int>(),typeof(UITypeEditor)).Dump();
4

1 に答える 1

0

次の行で何かを試してください

Customer任意のクラスです

EditorBaseと定義されている

public class EditorBase : System.Drawing.Design.UITypeEditor {
}

コード:

System.Collections.Hashtable table = new System.Collections.Hashtable();

table.Add(typeof(Customer), typeof(EditorBase).AssemblyQualifiedName);

System.ComponentModel.TypeDescriptor.AddEditorTable(typeof(System.Drawing.Design.UITypeEditor), table);

object editor = System.ComponentModel.TypeDescriptor.GetEditor(typeof(Customer), typeof(System.Drawing.Design.UITypeEditor));
于 2012-10-25T12:38:41.623 に答える