In one of my projects I\'m using an abstract UserControl. To be able to design this control in Visual Studio I\'m using the code proposed in this answer. Now I want to use t
I suppose you have a control AbstractGenericBase<T> : GenericBase<T>
which GenericBase<T>
is a control having such definition: GenericBase<T>: UserControl
.
So if you want to show AbstractGenericBase<T>
in designer, you can use this code:
using System.ComponentModel;
using System.Windows.Forms;
#if DEBUG
public abstract partial class AbstractGenericBase<T> : NonGenericBase
#else
public partial class AbstractGenericBase<T> : GenericBase<T>
#endif
{
public AbstractGenericBase()
{
InitializeComponent();
}
}
#if DEBUG
public class NonGenericBase : GenericBase<object> { }
#endif
Note
public abstract partial class AbstractGenericBase<T> : GenericBase<T>
T
has some type constraints, instead of object
in GenericBase<object>
use a Dummy
which satisfies the generic constraints.NonGenericBase
, but for run-time, we keep GenericBase<T>
as base class of our control.