ComponentOne Preview Classic for WinForms: C1PrintDocument Component > Styles

Styles

Most visual attributes of C1PrintDocument elements (such as fonts, colors, padding, and so on) are controlled by styles (C1DocStyle class). A render object's style is accessed through its Style property and is used when drawing the object. Also a style can be passed as a parameter when rendering content with one of the Render shortcut methods (that is, without creating a render object).

One of the most important characteristics of styles is inheritance. All styles in a document form a hierarchical tree. Except for the root document style (Document.Style), each style has a parent. When a new style is created, all of its attributes are inherited from the parent by default. This means that if an attribute in the parent style changes, that change is automatically propagated to all child styles unless that attribute has been specifically overridden in a child. This style attribute inheritance makes many tasks very convenient. For example, keeping documents' looks consistent becomes much easier and making sweeping changes in the documents is a snap.

When a new render object is created, its style is created together with the object. The parent of that new style is the root document style. It is important to keep in mind that while the object itself may be nested inside another object (for example, a row in a table), the hierarchy of styles is different – new styles in almost all cases (an exception is discussed below) inherit their attributes directly from the root document style. This allows you to conveniently fine-tune styles of individual document elements without inadvertently affecting the way nested elements look. Thus, typically if you want to change the look of the whole document (for example, set the default font), you would change the root document style. If, on the other hand, you want to modify just one element (for example, highlight a paragraph of text by making its text the color red), you would set the appropriate attribute of the style of that specific text paragraph.

A notable exception to that rule is tables. Table style rules are discussed in more detail in the Tables section.

Here is a full list of all 1st level attributes contained in a style, with a very brief description for each (for more detailed descriptions, see the reference section):

 

Attribute Name

Controls

Spacing

How much space is left around the element's border.

Padding

How much space is left inside the element's border.

Font

Text font.

Borders

Lines drawn around the element.

BackColor

Background fill color (covers padding but not spacing).

BackgroundImage

Background image (covers padding but not spacing).

BackgroundImageAlign

Background image alignment (including tile and stretch).

AlignChildrenHorz

How nested elements are aligned inside element.

AlignChildrenVert

How nested elements are aligned inside element.

AlignInParentHorz

How this element is aligned inside its parent.

AlignInParentVert

How this element is aligned inside its parent.

TextColor

Text color.

TextAngle

Text tilt angle.

TextAlignHorz

Horizontal text alignment.

TextAlignVert

Vertical text alignment.

LineSpacing

Text line spacing.

WordWrap

Whether text lines can be wrapped.

ImageAlign

Foreground image alignment.

ShapeLine

Line used to draw shapes (rectangles, ellipses, and so on).

ShapeFillColor

Color used to fill shapes.

BorderTableVert

For tables only – vertical borders between table elements.

BorderTableHorz

For tables only – horizontal borders between table elements.


Send comments about this topic to ComponentOne.
Copyright © 1987-2010 ComponentOne LLC. All rights reserved.