System.Windows.Forms.AxHost Class

Wraps ActiveX controls and exposes them as fully featured Windows Forms controls.

See Also: AxHost Members


[System.ComponentModel.Designer("System.Windows.Forms.Design.AxHostDesigner, System.Design, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
public abstract class AxHost : Control, System.ComponentModel.ICustomTypeDescriptor, System.ComponentModel.ISupportInitialize


You typically do not use the System.Windows.Forms.AxHost class directly. You can use the Windows Forms ActiveX Control Importer (AxImp.exe) to generate the wrappers that extend System.Windows.Forms.AxHost.

The ActiveX Control Importer generates a class that is derived from the System.Windows.Forms.AxHost class, and compiles it into a library file (DLL) that can be added as a reference to your application. Alternatively, you can use the /source switch with the ActiveX Control Importer and a C# file is generated for your System.Windows.Forms.AxHost derived class. You can then make changes to the code and recompile it into a library file.


If the name of a member of the ActiveX control matches a name defined in the .NET Framework, then the ActiveX Control Importer will prefix the member name with "Ctl" when it creates the System.Windows.Forms.AxHost derived class. For example, if your ActiveX control has a member named "Layout", it is renamed "CtlLayout" in the System.Windows.Forms.AxHost derived class because the Layout event is defined within the .NET Framework.

Most of the common properties of the System.Windows.Forms.AxHost class are only valid and used if the underlying ActiveX control exposes those properties. A few examples of the common properties are Control.BackColor, Control.Cursor, Control.Font, and Control.Text.


If you are using Visual Studio as your Windows Forms design environment, you can make an ActiveX control available to your application by adding the ActiveX control to your Toolbox. To accomplish this, right-click the Toolbox, select Customize Toolbox, then browse to the ActiveX control's.ocx file. For more information, see "Adding ActiveX Controls to Windows Forms" in the Visual Studio documentation.


Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0,