PrintDocument for WinForms | ComponentOne
C1.PrintDocument.8 Assembly / C1.C1Preview Namespace / Unit Structure / Unit Constructor / Unit Constructor(String)
A string representing the value.

In This Topic
    Unit Constructor(String)
    In This Topic
    Initializes a new instance of the Unit structure from a string. See remarks for details.
    Syntax
    'Declaration
     
    Public Function New( _
       ByVal str As String _
    )
    public Unit( 
       string str
    )

    Parameters

    str
    A string representing the value.
    Remarks

    (In the description that follows, "object" means a RenderObject or another document object on which the current Unit represents a dimension or a coordinate, not the Unit structure itself.)

    The str string should contain a valid Unit value in one of the following forms:
    • Auto, represented by the string "auto". The exact semantics depend on the type of object with which the current unit is associated.
    • An unqualified numeric value, e.g. "8" or "100.12".

      In this case C1PrintDocument.DefaultUnit determines the unit of measurement.

    • A numeric value qualified with unit of measurement, e.g. "28mm" or "7in".

      The following unit type qualifiers are supported (for each type, the corresponding element of the UnitTypeEnum enumeration is listed):

    • A percentage of the object's parent size, optionally qualified with the parent's dimension ("width" or "height"; if a dimension is not specified, the dimension the current unit referes to is assumed), e.g. "50%width" or "120%".

      (Percentage can only be used to specify width or height, and is not valid for coordinates.)

    • A reference to a dimension or coordinate of another object, e.g. "prev.width", "next.bottom" or "page1column2.width".

      The referenced object may be identified by any of the following key words:

      • The current object. Default, may be omitted;
      • The current object's parent (container);
      • The previous sibling of the current object;
      • The next sibling of the current object;
      • The current page;
      • The current page column;
      • Page by number, N is 1-based (e.g. "page8"; the page must already exist - forward references using this notation are not supported);
      • Page by index, N is 0-based (e.g. "page0");
      • Column by number, M is 1-based, on the current page (e.g. "column2");
      • Column M on page N, M and N are 1-based (e.g. "page8.column2");
      • Object with the specified name (see RenderObject.Name). The object is first searched among the siblings of the current object, then among its children.
      The referenced dimension or coordinate may be specified using any of the following key words: leftThe X coordinate of the left edge of an object; topThe Y coordinate of the top edge of an object; rightThe X coordinate of the right edge of an object; bottomThe Y coordinate of the bottom edge of an object; widthThe width of an object; heightThe height of an object.
    • A Max or Min built-in function call, e.g. "Max(prev.width,6cm)" or "Min(0.5in,next.height)".
    • An expression using operands in any of the forms described above (except "auto"), combined using operators + (add), - (subtract), * (multiply), / (divide), % (percent), functions Min and Max, and parentheses ( and ).

      Examples of unit expressions are:

      • This expression can be used to specify the width of an object being 1.5 times the width of its previous sibling
      • Same as above
      • Same as above but using multiplication instead of percentage
    See Also