I'm making a C# user control, that is used as an ActiveX control. Usually a C# user control derives from System.Windows.Forms.UserControl
. That is what Visual Studio wizards will give you:
public partial class UserControl1 : UserControl
and that is what I've seen in all code examples I've come across on the web.
But I use a third party dll, that can only work with a Form. So I tried to make my Active X control inherit from System.Windows.Forms.Form
:
public partial class UserControl1 : System.Windows.Forms.Form
and that seems to work, if I set TopLevel to false in the constructor. I can compile and register my dll with regasm, and use the ActiveX control in a C++/MFC hosting/test program. And it works.
But I wonder if there are any disadvantages of deriving from Form
instead of UserControl
? Am I up for trouble down the road? Is there a good reason why I have not seen this construction anywhere else? Anything I ought to be aware of?
I hope my question is not too vague or broad.