ジェネリックは、型なしでクラスをインスタンス化できないため、デザイナーを壊しますT
。ブログ投稿で回避策を説明しています。
http://adamhouldsworth.blogspot.co.uk/2010/02/winforms-visual-inheritance-limitations.html
つまり、中間クラスで型を「解決」する必要があります。
BaseControl<T> : UserControl
CustomerControl_Design : BaseControl<Customer>
CustomerControl : CustomerControl_Design
DEBUG
次に、またはRELEASE
コンパイラ スイッチに基づいて、コードからこのクラスを条件付きで切り替えることができます。
#if DEBUG
namespace MyNamespace
{
using System;
public partial class CustomerEditorControl_Design : BaseEditorControl<Customer>
{
public CustomerEditorControl_Design()
: base()
{
InitializeComponent();
}
}
}
#endif
public partial class CustomerEditorControl
#if DEBUG
: CustomerEditorControl_Design
#else
: BaseEditorControl<Customer>
#endif
{
}
これにより、 の派生クラスを開くことCustomerControl
ができますが、残念ながら、シグネチャにジェネリックを含む UI コントロールを設計することはできません。私の解決策は、派生アイテムの設計のみを有効にすることです。
CustomerControl : BaseControl<Customer>
この場合、型が定義されているため、なぜ機能しないのT
かわかりませんが、単純に機能しません-一般的な使用法の規則のために推測しています。
彼らの弁護のために、マイクロソフトはこれがサポートされていないと言っています.