I'm struggling with a situation that I come up again time and time again but I am not sure whether the way that I am doing things is wrong or whether I could be doing things in a different way.
An Example:
I have a Windows Form that has a DataGridView with some private methods to perform validation of the datagrid and interpreting right mouse clicks on the datagridview etc. This windows form is essentially an "abstract" class and is never instantiated directly.
I then inherit from this base class and customise it in various ways (template pattern) e.g. define the columns of the datagridview and particular formatting methods which are specific to those columns etc.
When I consume these classes the base class public methods form my interface and I can instantiate the particular type of datagridview that I want and manipulate it through the common interface. Lovely.
The Problem:
The main problem is that you cannot actually declare a Windows Form class as abstract without causing the Visual Studio designer to throw a wobbly as it cannot instantiate these abstract classes.
Some Solutions:
At the moment I am "implementing" those methods in the base class that I want to be overridden with:
throw new NotSupportedException();
so at least if I forget to override one of these methods that form my interface. This seems rather smelly to me though and I don't really like it.
Another solution I toyed with was to do away with inheritance altogether and define an interface (e.g. IMyDataGrid) and implement that in each datagridview class (sort of strategy pattern). The problem here though is that you lose the benefits of code re-use that inheritance gives you meaning that you have to create many different forms, drop a datagridview on them - effectively copy and pasting the same code into each one. Bad.
Is there a better way of trying to achieve this?