PrintDocument for WinForms | ComponentOne
C1.PrintDocument.4.8 Assembly / C1.C1Preview Namespace / Style Class / AmbientParent Property
Example

In This Topic
    AmbientParent Property (Style)
    In This Topic
    Gets or sets the Style that is the ambient parent of the current style.

    If non-null, that style provides the values for ambient properties of the current style that have not been explicitly set.

    If null, such properties are inherited from the style of the containing object.

    This property is null by default.

    Syntax
    'Declaration
     
    Public Property AmbientParent As Style
    public Style AmbientParent {get; set;}
    Remarks
    Initially a Style object does not have any explicitly set properties. This means that the effective values of all ambient properties (such as font) are inherited from the style of the containing object, unless this property has been set to a non-null value, in which case they are inherited from that style.

    Note that even if an AmbientParent has been specified, only ambient properties that have been explicitly set on that style or any of its own ambient parents (styles or containing objects) propagate to the current style. See example below for details.

    Example
    For instance, the following code: still prints "my text" in bold, while this code: prints "my text" using regular (non-bold) font. This is because FontBold has been explicitly set to false on the style assigned to the AmbientParent on the text object.
    C1PrintDocument doc = new C1PrintDocument();
    RenderArea ra = new RenderArea();
    ra.Style.FontBold = true;
    RenderText rt = new RenderText("my text");
    ra.Style.AmbientParent = doc.Style;
    ra.Children.Add(rt);
    doc.Body.Children.Add(ra);
    C1PrintDocument doc = new C1PrintDocument();
    doc.Style.FontBold = false; // this line makes the difference!
    RenderArea ra = new RenderArea();
    ra.Style.FontBold = true;
    RenderText rt = new RenderText("my text");
    ra.Style.AmbientParent = doc.Style;
    ra.Children.Add(rt);
    doc.Body.Children.Add(ra);
    See Also