Name
AxHost
Synopsis
This Control
class wraps ActiveX controls that
have been imported into the managed environment (either by use of the
Aximp.exe
tool or, more commonly, by adding them
to the designer by customizing the toolbox). It extends the base
services to provide methods to get the underlying OCX control
(GetOcx()
) and show property pages
(ShowPropertyPages()
), if they are present
(HasPropertyPages()
).
Note that several of the events you would normally expect from a
Control
are not supported (e.g., color and font
property changes), and attempting to bind to them will cause a
NotSupportedException
. The Liskov substitution
principle states that you should be able to use any instance of a
derived class in place of an instance of the base class. Throwing
that exception means that this class violates that principle.
Therefore, you have to take care if you are using
Control
objects polymorphically in your
application (e.g., in your own custom host), in case someone drops an
ActiveX control into the equation.
public abstract class AxHost : Control : System.ComponentModel.ISupportInitialize, System.ComponentModel.ICustomTypeDescriptor { // Protected Constructors protected AxHost(string clsid); protected AxHost(string clsid, int flags); // Public Instance Properties public override Color BackColor{set; get; } // overrides Control public override Image BackgroundImage{set; get; } // overrides Control public ContainerControl ContainingControl{set; get; } public override ContextMenu
Get .NET Windows Forms in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.