开发者

.NET ActiveX Interop - Dynamically adding a control

开发者 https://www.devze.com 2023-02-10 20:53 出处:网络
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 current

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消