.NET ActiveX Interop - Dynamically adding a control
I am trying to create a WinForms app that will allow the user to enter the ProgID (and possible ClsID if necessary) of any registered ActiveX COM control, and have the form load that control. I currently have the following:
public static class prog
{
public static string progID = "Control.ControlName";
}
[ProgId(prog.progID)]
class GenericControl
{
}
and then am trying to use this inside the form as follows:
Control newctl;
newctl = (Control)new GenericControl();
this.Controls.Add();
Obviously, this doesn't work - it tells me that I can't convert GenericControl to Control. I've found a few articles on Interop, but they seem to assume that you know the control at design time. Is what I'm trying to开发者_高级运维 do possible, and if so, how?
精彩评论