1

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.

Collin
  • 11,977
  • 2
  • 46
  • 60
Johan
  • 31
  • 3
  • possibly useful link: http://www.pcreview.co.uk/forums/difference-between-winforms-and-user-controls-t1319966.html – Arie May 08 '14 at 13:03
  • @Arie: Thanks. That was useful. I also found these two discussions of Form vs. UserControl: http://stackoverflow.com/questions/821094/embedded-form-in-a-control-or-form-as-user-control and http://stackoverflow.com/questions/2299339/user-control-vs-windows-form – Johan May 12 '14 at 11:43

0 Answers0