Can't design control inherited from generic control
I created a control, the QuestionPanel, with generic type parameters, and now I want to inherit another control from it. However, when I try to do so, I get this error in the form designer:
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: TrueFalseQuestionPanel The base class 'Survey.UI.QuestionPanel' could not be loaded. Ensure the assembly has been referenced and that all projects have been built.
The QuestionPanel class, however, works perfectly fine in its own designer! I have tried rebuilding the project to no avail. Do I need to define a custom designer for my QuestionPanel class or something? That doesn't seem to make much sense, as previous versions of Visual Studio let me create inherited controls without creating custom designers...
[873 byte] By [
ekolis] at [2007-12-20]
Both the base control and the derived control have empty public constructors.
I did however have to add the generic parameter list to the QuestionPanel.Designer.cs partial class definition for the code to compile at all; without it I got the error "no suitable method found to override" on the Dispose event handler. I imagine this is because QuestionPanel and QuestionPanel<QT, AT> are different types.
We figured out a solution for this problem as you can see in this this thread.
What we did was created a class that inherited from the typed user control and specified a class in there, then we created a new Inherited UserControl and inherit your typed class in code, then it will show up in the designer.
Thanks for the info, but we loose most of the benefits of using generics, since we would have to create new classes everytime need to change just a datatype. I was thinking more of a CustomerDesigner that asked you once you drop the control from the toolbar, what types do you want to make this. And this should be something you change on design time.
By now we have been doing all the coding of this generic controls without designer support.