The Inherited Form wizard cannot show your base Form class among the available compatible classes because the derived class needs to define the concrete Type of T; the Inheritance Picker offers no means to specify this.
You can simply create a new Form, then change the Type it inherits from and the Type of the generic type parameters defined in the base class.
E.g., create a Form named SomeDerivedForm:
public partial class SomeDerivedForm : Form {
public SomeDerivedForm() => InitializeComponent();
}
then change it in (no changes in the Designer.cs file):
public partial class SomeDerivedForm : SomeBaseForm<SomeType> {
public SomeDerivedForm() => InitializeComponent();
}
The design of generic classes, without an intermediate non-generic class, is available since Visual Studio 2015 Update 1 (.NET Framework)
Other problems in the code presented here that prevent the derived class to show Controls added to the base class (or to function entirely for that matter):
- The default Constructor should not be
private, it should be - if that is required - internal or protected internal
- Of course the default Constructor must call the
InitializeComponent() method
- Overloaded Constructors should call the default Constructor first
In your case, the code can be changed in:
public partial class DetailViewBase<TEntity> : Form where TEntity : class, new()
{
internal DetailViewBase() => InitializeComponent();
public DetailViewBase(int? id) : this() {
Id = id;
}
// [...]
}
In the Designer.cs file, the class is defined as:
partial class DetailViewBase<TEntity> { //[...] }
Some more information related to the initialization sequence in a derived Form:
How to get the size of an inherited Form in the base Form?