Use ActiveX Control in a Class

R

rzaleski

Is there a way to initialize an ActiveX control in a class? I tried
copying over the code that was auto generated when I added the control
to a form, but I am hung up on the following line:

this.mycontrol.OcxState = ((System.Windows.Forms.AxHost.State)
(resources.GetObject("mycontrol.OcxState")));

Is there any other way to accomplish this?
 
F

Fredo

You shouldn't have to set the OcxState unless you're trying to restore
previously saved settings. My understanding is that this is the way that you
can set properties for the ActiveX control and have the form designer be
able to serialize those settings into the .RESX file. So there's no point in
restoring those settings if you're setting those properties
programmatically...
 
R

rzaleski

You shouldn't have to set the OcxState unless you're trying to restore
previously saved settings. My understanding is that this is the way that you
can set properties for the ActiveX control and have the form designer be
able to serialize those settings into the .RESX file. So there's no point in
restoring those settings if you're setting those properties
programmatically...

Here's my problem. I add the control to a form and can do everything
fine (set its properties, etc). If I try to create an object in a
class, I get the following error:

"An unhandled exception of type 'InvalidActiveXStateException'
occurred in axinterop.finsctllib.dll"

Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top