I am building a WinForms custom control which extends DataGridView.
interface IMyControl<A, B> { }
public partial class MyControl<A, B> : DataGridView, IMyControl<A, B>
{
}
A and B are business domain object types.
However, the code will not compile. The MyControl.Designer.cs cannot be compiled.
protected override void Dispose(bool disposing) //no suitable method found to override
{
if (disposing && (components != null))
{
components.Dispose();
}
//'object' does not contain a definition for 'Dispose'
base.Dispose(disposing);
}
‘Infrastructure.MyControl.Dispose(bool)’: no suitable method found to override MyControl.Designer.cs
You can’t have generic controls.
Try this:
Leave whatever generic code you currently have in the generic base class. The wrapper classes can be very thin because then only serve to provide a non-generic Control to add to your form.