This is a discussion on Access to members of a AxHost (OCX) dynamically instantiated. - DOTNET ; Hi, Please check the following code: Now, after having ActiveX well... How do to access the ActiveX's members ? using System; using System.ComponentModel; namespace WrapOCX ( public class AxControl : System.Windows.Forms.AxHost { public AxControl(string cLSID): base(cLSID){ } } public class ...
Hi,
Please check the following code:
Now, after having ActiveX well... How do to access the ActiveX's members ?
using System;
using System.ComponentModel;
namespace WrapOCX
(
public class AxControl : System.Windows.Forms.AxHost
{
public AxControl(string cLSID): base(cLSID){ }
}
public class AXContainer : System.Windows.Forms.UserControl
{
WrapOCX.AxControl _axControl = null;
String _progID = String.Empty;
public String ProgID
{
get
{
return _progID;
}
set
{
_progID = value;
this.SetActiveX();
}
}
private void SetActiveX()
{
this.Controls.Clear();
this._axControl = null;
Type ty = Type.GetTypeFromProgID(_progID); // eg. OVCt1.OVCt1.1 It's MSOffice(2007)
// Outlook View.
this._axControl = new WrapOCX.AxControl(ty.GUID.ToString());
((ISupportInitialize)(this._axControl)).BeginInit();
this.SyspendLayout();
this._axControl.Name = "axControl";
this._axControl.TabIndex = 0;
this._axControl.Dock = DockStyle.Fill;
this.Show();
this.Controls.Add(this._axControl);
((ISupportInitialize)(this._axControl)).EndInit();
this.ResumeLayout();
}
}
)
-> Now, after having ActiveX well... How do to access the ActiveX's members ?
Alvaro.