In my application, I have a BaseForm
which has a generic member in it:
public partial class BaseForm<T> : Form where T : Presenter
{
protected T Presenter;
public BaseForm()
{
InitializeComponent();
}
}
Now what i need is to have a form which is inherited from my BaseForm
public partial class SampleForm : BaseForm<SamplePresenter>
{
public SampleForm()
{
InitializeComponent();
Presenter = new SamplePresenter();
}
}
The problem is that the Visual Studio designer does not show my SampleForm
derived from BaseForm<T>
.
It gives this warning:
Warning 1 The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file:
SampleForm --- The base class 'Invoice.BaseForm' could not be loaded. Ensure the assembly has been referenced and that all projects have been built. 0 0
How can I overcome this?
P.S. I looked at this post but didn't really get the whole idea of how to solve this.
The designer doesn't support this, as described in that post.
You need this base class:
public partial class SampleFormIntermediate : BaseForm<SamplePresenter>
{
public SampleFormIntermediate()
{
InitializeComponent();
Presenter = new SamplePresenter();
}
}
And you need to use this class for the Visual Studio designer:
public partial class SampleForm : SampleFormIntermediate
{
}
In that way, Visual Studio 'understands' what to open in the designer and how to open it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With