ComponentOne VSView 8.0
Styles Property

Returns a collection of styles that can be applied to the document.

Syntax

val% = [form!]VSPrinter.Styles

Remarks

A VSPrinter"Style" is a group of properties that affect the appearance of text and graphical elements that are rendered on the page.

The Styles collection is an object that exposes methods that allow you to create, apply, and manage styles. The methods and properties exposed by the Styles object are described below:

vp.Styles.SetPageExtent

Method that removes all styles from the collection.

val% = vp.Styles.Count

Property that returns the number of styles in the Styles collection.

vp.Styles.Add(Key As String, Flags As StyleFlagsSettings)

Method that defines a new style based on the VSPrinter control's current settings. The new style is saved into the collection under the name Key (if a style by that name is already defined, it is overwritten).

The Flags parameter specifies which style elements should be saved. Valid settings for the Flags parameter are:

 

Symbol

Value

Saves/Restores

vpsCharacter

1

Font, TextColor, and TextAngle properties.

vpsParagraph

2

SpaceBefore, SpaceAfter, LineSpacing, Indent*, and TextAlign properties.

vpsGraphics

4

Brush*, Pen*, TablePen*, and TableBorder properties.

vpsContent

7

All of the above (vpsCharacter + vpsParagraph + vpsGraphics).

vpsPage

8

Margin*, Columns, ColumnSpacing, and PageBorder properties.

vpsAll

65535

All of the above.

 

vp.Styles.Remove(Index As Variant)

Deletes the given style, removing it from the collection. The Index parameter should correspond to the name of an existing style, or it should be an index ranging from zero to vp.Styles.Count - 1.

vp.Styles.Apply(Index As Variant)

Applies the given style to the VSPrinter control, modifying the set of properties defined when the style was created.

vp.Styles.Key(Index As Variant) [ = NewKey As String]

Returns or sets the name (key) for a given style. If NewKey has already been assigned to another style, an Invalid Index error will occur.

val% = vp.Styles.Flags(Index As Variant)

Returns the flags associated with a given style when the style was defined.

vp.Styles.Save(FileName As String)

Saves the current Styles collection to a disk file.

vp.Styles.Load(FileName As String)

Loads a set of styles from a disk file into the Styles collection. Existing styles are preserved, unless a style being loaded has the same name as an existing style, in which case the existing style is overwritten with the one being loaded form disk.

Styles are useful for two main purposes:

1.   To define a consistent look for your documents. You can set up a routine that defines a basic set of styles and is completely separate from the routine that generates the document using the predefined styles. If you decide to change the styles, or to implement different "templates" for your documents, change only the routine that defines the styles, and not the one that generates the documents. You can even save the styles to disk and share the styles among several applications. For example:

Sub DefineStyles()

  vp.FontName = "Tahoma"

  vp.FontSize = 10

  vp.SpaceAfter = "8pt"

  vp.Styles.Add "Normal", vpsAll

  vp.FontSize = "14"

  vp.SpaceBefore = "1in"

  vp.Styles.Add "Title", vpsAll

End Sub

 

Sub CreateDocument()

  vp.Startdoc

  vp.Styles.Apply "Title"

  vp.Paragraph = "Welcome to VSPrinter Styles"

  vp.Styles.Apply "Normal"

  vp.Paragraph = "This is the normal style."

  vp.EndDoc

End Sub

2.   Styles allow you to save and restore the control state easily and efficiently. Instead of saving a large number of properties, creating the output you want, and then restoring the saved properties, you can simply define a "Scratch" style, make all the changes you want, then restore the "Scratch" style. For example:

vp.Styles.Add "Scratch", vpsAll

vp.FontName = "Symbol"

vp.IndentLeft = "2in"

vp.Paragraph = "Bet you can't read this!"

vp.Styles.Apply "Scratch"

Data Type

IVSPrinterStyle

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback