Name
AmbientProperties
Synopsis
The Site
is the object that hosts a
Control
. Control
objects can
inherit certain properties from their Site
, and
these are called ambient properties. At present, the ambient
properties are ForeColor
,
BackColor
, Cursor
, and
Font
. If you haven’t specified a
particular value for any of these properties, the control will
retrieve an AmbientProperties
object from the site
by using the GetService()
method. The service
required is typeof(AmbientProperties)
. The control
can pull the ambient value from it. If the control is not hosted in a
site, or if the site doesn’t support ambient
properties, the Control.DefaultXXX
member will be
used to provide the value instead.
public sealed class AmbientProperties { // Public Constructors public AmbientProperties(); // Public Instance Properties public Color BackColor{set; get; } public Cursor Cursor{set; get; } public Font Font{set; get; } public Color ForeColor{set; get; } }
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.