Dynamically add ActiveX control to VB.NET Form 
Author Message
 Dynamically add ActiveX control to VB.NET Form

Our current VB6 application dynamically adds ActiveX controls to child MDI
forms following the "Dynamic MDI Forms" approach published in the March
Visual Basic Programmers Journal, available in MSDN.

We are trying to port this application to VB.NET, but we can not figure out
how to dynamically load our forms which are COM based onto a VB.NET form.

We can sucessfully dynamically create a COM object from VB.NET like so:

ObjectType = type.GetTypeFromProgID("projectname.classname")
NewObject = Activator.CreateInstance(ObjectType)

But the succcess ends there.  Any suggestions?  Is this even possible?

In desperation..

Cheers,
  Ewart.


keywords:  OCX user controls, COM forms



Tue, 03 May 2005 09:55:07 GMT  
 Dynamically add ActiveX control to VB.NET Form
The following article might help you.

HOW TO: Dynamically Add ActiveX Controls that Require Run-Time Licenses in
Visual Basic .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;326651

Cheers,
Bob


Quote:
> Our current VB6 application dynamically adds ActiveX controls to child MDI
> forms following the "Dynamic MDI Forms" approach published in the March
> Visual Basic Programmers Journal, available in MSDN.

> We are trying to port this application to VB.NET, but we can not figure
out
> how to dynamically load our forms which are COM based onto a VB.NET form.

> We can sucessfully dynamically create a COM object from VB.NET like so:

> ObjectType = type.GetTypeFromProgID("projectname.classname")
> NewObject = Activator.CreateInstance(ObjectType)

> But the succcess ends there.  Any suggestions?  Is this even possible?

> In desperation..

> Cheers,
>   Ewart.


> keywords:  OCX user controls, COM forms



Tue, 03 May 2005 12:46:33 GMT  
 Dynamically add ActiveX control to VB.NET Form
Thanks Bob, I looked at that but unfortuantely that article does not truly
describe how to DYNAMICALLY load controls.  I need to load it dynamically
rather than creating a reference at design time - the control will not exist
at design time.

anyone got any ideas?  seems Microsoft have {*filter*}ed up this part of the
design for .net

rgds,
ewart.

Quote:
> The following article might help you.

> HOW TO: Dynamically Add ActiveX Controls that Require Run-Time Licenses in
> Visual Basic .NET
> http://www.*-*-*.com/ ;en-us;326651

> Cheers,
> Bob



> > Our current VB6 application dynamically adds ActiveX controls to child
MDI
> > forms following the "Dynamic MDI Forms" approach published in the March
> > Visual Basic Programmers Journal, available in MSDN.

> > We are trying to port this application to VB.NET, but we can not figure
> out
> > how to dynamically load our forms which are COM based onto a VB.NET
form.

> > We can sucessfully dynamically create a COM object from VB.NET like so:

> > ObjectType = type.GetTypeFromProgID("projectname.classname")
> > NewObject = Activator.CreateInstance(ObjectType)

> > But the succcess ends there.  Any suggestions?  Is this even possible?

> > In desperation..

> > Cheers,
> >   Ewart.


> > keywords:  OCX user controls, COM forms



Thu, 05 May 2005 06:25:30 GMT  
 Dynamically add ActiveX control to VB.NET Form
Hi Ewart,
Not sure if I'm on the right track and if this of any help. But what I
do is to reference the particular ActiveX control in my project by
adding it to the toolbox which is available when displaying a form in
the designer in the .net IDE. Subsequently I create an instance of the
activeX control just as I would in VB6 by adding it to the form:

' only got IDispatch here
   MyActiveXobj = New AxMyCtrlObjLib.AxMyCtrlObj()

' ActiveX obj must connect to the container's interfaces when
' put on the container. Otherwise it doesn't know where it is
   Me.Controls.Add(MyActiveXobj)
' do something with the control
  MyActiveXobj.left = 0
  MyActiveXobj.top = 42
  MyActiveXobj.DoIt

I think this should instantiate your ActiveX control properly.

HTH,

Rob

Quote:

> Thanks Bob, I looked at that but unfortuantely that article does not truly
> describe how to DYNAMICALLY load controls.  I need to load it dynamically
> rather than creating a reference at design time - the control will not exist
> at design time.

> anyone got any ideas?  seems Microsoft have {*filter*}ed up this part of the
> design for .net

> rgds,
> ewart.



Sun, 08 May 2005 21:57:26 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Dynamically add ActiveX control to VB.NET Form

2. How to add an activex control dynamically in VB.NET

3. Dynamically adding ActiveX controls to a form?

4. Need help dynamically adding ActiveX controls to an MDI child window

5. Add user control to Web Form dynamically

6. Adding controls to a form dynamically

7. Dynamically adding a custom control to a form during runtime

8. Dynamically adding dropdown lists to a form's controls collection

9. Adding Controls to a form dynamically

10. Dynamically adding controls to a form at runtime

11. Adding Controls on a Empty Form Dynamically

12. Dynamically adding controls to form

 

 
Powered by phpBB® Forum Software