Show / Hide Table of Contents

Class Base

Represents the root class of the FastReport object's hierarhy.

Inheritance
System.Object
Base
ComponentBase
CommandParameter
DataComponentBase
Dictionary
Parameter
Total
ExportBase
Report
Implements
IFRSerializable
Namespace: FastReport
Assembly: FastReport.OpenSource.dll
Syntax
public abstract class Base : Component, IFRSerializable

Constructors

Base()

Initializes a new instance of the Base class with default settings.

Declaration
public Base()

Properties

AllObjects

Gets the collection of all child objects.

Declaration
public ObjectCollection AllObjects { get; }
Property Value
Type Description
ObjectCollection
Remarks

This property returns child objects that belongs to this object and to child objects of this object. For example, Report.AllObjects will return all objects that contains in the report - such as pages, bands, text objects.

BaseName

The base part of the object's name.

Declaration
public string BaseName { get; set; }
Property Value
Type Description
System.String
Remarks

This property is used to automatically create unique object's name. See CreateUniqueName()

ChildObjects

Gets the collection of this object's child objects.

Declaration
public ObjectCollection ChildObjects { get; }
Property Value
Type Description
ObjectCollection
Remarks

This property returns child objects that belongs to this object. For example, Report.ChildObjects will return only pages that contains in the report, but not page childs such as bands. To return all child objects, use AllObjects property.

ClassName

Gets the short type name.

Declaration
public string ClassName { get; }
Property Value
Type Description
System.String
Remarks

Returns the short type name, such as "TextObject".

Flags

Gets the flags that allow some functionality in the designer.

Declaration
public Flags Flags { get; }
Property Value
Type Description
Flags
Remarks

Use this property only if you developing a new FastReport object.

IsAncestor

Gets a value indicating whether the object was introduced in the ancestor report.

Declaration
public bool IsAncestor { get; }
Property Value
Type Description
System.Boolean

IsDesigning

Gets a value indicating whether the object is in the design state.

Declaration
public bool IsDesigning { get; }
Property Value
Type Description
System.Boolean

IsPrinting

Gets a value indicating whether the object is currently printing.

Declaration
public bool IsPrinting { get; }
Property Value
Type Description
System.Boolean

IsRunning

Gets a value indicating whether the object is currently processed by the report engine.

Declaration
public bool IsRunning { get; }
Property Value
Type Description
System.Boolean

Name

Gets or sets the name of the object.

Declaration
public virtual string Name { get; set; }
Property Value
Type Description
System.String
Remarks

Name of the report object must contain alpha, digit, underscore symbols only. Data objects such as Variable, TableDataSource etc. can have any characters in they names. Each component must have unique name.

Examples

The following code demonstrates how to find an object by its name:

TextObject text1 = report1.FindObject("Text1") as TextObject;
Exceptions
Type Condition
DuplicateNameException

Another object with such name exists.

AncestorException

Rename an object that was introduced in the ancestor report.

OriginalComponent

Gets an original component for this object.

Declaration
public Base OriginalComponent { get; set; }
Property Value
Type Description
Base
Remarks

This property is used in the preview mode. Each object in the prepared report is bound to its original (from the report template). This technique is used to minimize the prepared report's size.

Page

Gets reference to the parent PageBase object.

Declaration
public PageBase Page { get; }
Property Value
Type Description
PageBase

Parent

Gets or sets the parent of the object.

Declaration
public Base Parent { get; set; }
Property Value
Type Description
Base
Remarks

Each report object must have a parent in order to appear in the report. Parent must be able to contain objects of such type.

Another way (preferred) to set a parent is to use specific properties of the parent object. For example, the Report object has the Pages collection. To add a new page to the report, use the following code: report1.Pages.Add(new ReportPage());

Examples
    Report report1;
    ReportPage page = new ReportPage();
    page.Parent = report1;
Exceptions
Type Condition
ParentException

Parent object cannot contain this object.

Report

Gets reference to the parent Report object.

Declaration
public Report Report { get; }
Property Value
Type Description
Report

Restrictions

Gets or sets the flags that restrict some actions in the designer.

Declaration
public Restrictions Restrictions { get; set; }
Property Value
Type Description
Restrictions
Remarks

Use this property to restrict some user actions like move, resize, edit, delete. For example, if Restriction.DontMove flag is set, user cannot move the object in the designer.

ZOrder

Gets or sets the Z-order of the object.

Declaration
public int ZOrder { get; set; }
Property Value
Type Description
System.Int32
Remarks

The Z-order is also called "creation order". It is the index of an object in the parent's objects list. For example, put two text objects on a band. First object will have ZOrder = 0, second = 1. Setting the second object's ZOrder to 0 will move it to the back of the first text object.

Methods

Assign(Base)

Copies the contents of another, similar object.

Declaration
public virtual void Assign(Base source)
Parameters
Type Name Description
Base source

Source object to copy the contents from.

Remarks

Call Assign to copy the properties from another object of the same type. The standard form of a call to Assign is

destination.Assign(source);

which tells the destination object to copy the contents of the source object to itself. In this method, all child objects are ignored. If you want to copy child objects, use the AssignAll(Base) method.

Examples
    Report report1;
    Report report2 = new Report();
    // copy all report settings, do not copy report objects
    report2.Assign(report1);
See Also
AssignAll(Base)

AssignAll(Base)

Copies the contents (including children) of another, similar object.

Declaration
public void AssignAll(Base source)
Parameters
Type Name Description
Base source

Source object to copy the state from.

Remarks

This method is similar to Assign(Base) method. It copies child objects as well.

Examples
    Report report1;
    Report report2 = new Report();
    // copy all report settings and objects
    report2.AssignAll(report1);
See Also
Assign(Base)

BaseAssign(Base)

Assigns values from another source.

Declaration
public void BaseAssign(Base source)
Parameters
Type Name Description
Base source

Source to assign from.

Remarks

Note: this method is relatively slow because it serializes an object to the xml and then deserializes it.

Clear()

Clears the object's state.

Declaration
public virtual void Clear()
Remarks

This method also disposes all object's children.

CreateUniqueName()

Creates the unique object's name.

Declaration
public void CreateUniqueName()
Remarks

Note: you have to set object's parent before calling this method. Method uses the BaseName property to create a name.

Note: this method may be very slow on a report that contains lots of objects. Consider using own naming logic in this case.

Examples
TextObject textObj = new TextObject();
dataBand1.Objects.Add(textObj);
textObj.CreateUniqueName();

Deserialize(FRReader)

Deserializes the object.

Declaration
public virtual void Deserialize(FRReader reader)
Parameters
Type Name Description
FRReader reader

Reader object.

Remarks

Do not call this method directly. You should override it if you are developing a new component for FastReport.

This method is called when the object needs to restore the state. It may happen when:

  • loading the report from a file or stream;
  • loading the report from the designer's undo buffer;
  • assigning another object to this object using the Assign(Base) or AssignAll(Base) methods;
  • loading the object from the designer's clipboard;

DeserializeSubItems(FRReader)

Deserializes nested object properties.

Declaration
protected virtual void DeserializeSubItems(FRReader reader)
Parameters
Type Name Description
FRReader reader

Reader object.

Remarks

Typically the object serializes all properties to the single xml item:

<TextObject Name="Text2" Left="18.9" Top="37.8" Width="283.5" Height="28.35"/>

Some objects like DataBand have child objects that serialized in subitems:

<DataBand Name="Data1" Top="163" Width="718.2" Height="18.9">
  <TextObject Name="Text3" Left="18.9" Top="37.8" Width="283.5" Height="28.35"/>
</DataBand>

To read such subitems, the DeserializeSubItems method is used. Base implementation reads the child objects. You may override it to read some specific subitems.

Examples

The following code is used to read report's styles:

protected override void DeserializeSubItems(FRReader reader)
{
  if (String.Compare(reader.ItemName, "Styles", true) == 0)
    reader.Read(Styles);
  else
    base.DeserializeSubItems(reader);
}

Dispose(Boolean)

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
System.Boolean disposing

ExtractDefaultMacros(String)

Replaces the macros in the given string and returns the new string.

Declaration
protected string ExtractDefaultMacros(string text)
Parameters
Type Name Description
System.String text

The text containing macros.

Returns
Type Description
System.String

The text with macros replaced with its values.

ExtractMacros()

Used to extract macros such as "TotalPages#" in the preview mode.

Declaration
public virtual void ExtractMacros()
Remarks

This method is used mainly by the TextObject to extract macros and replace it with actual values passed in the pageIndex and totalPages parameters. This method is called automatically when the object is being previewed.

FindObject(String)

Searches for an object with given name.

Declaration
public virtual Base FindObject(string name)
Parameters
Type Name Description
System.String name

Name of the object to find.

Returns
Type Description
Base

Returns a null reference if object is not found

Examples

The following code demonstrates how to find an object by its name:

TextObject text1 = report1.FindObject("Text1") as TextObject;
if (text1 != null) 
{ 
  // object found 
}

FloatDiff(Single, Single)

Checks if two float values are different.

Declaration
protected bool FloatDiff(float f1, float f2)
Parameters
Type Name Description
System.Single f1

First value.

System.Single f2

Second value.

Returns
Type Description
System.Boolean

true if values are not equal.

Remarks

This method is needed to compare two float values using some precision (0.001). It is useful to compare objects' locations and sizes for equality.

ForEachAllConvectedObjects(Object)

Gets the collection of all child objects, converts objects if necessary

Declaration
public ObjectCollection ForEachAllConvectedObjects(object sender)
Parameters
Type Name Description
System.Object sender

the object or export, that call this convertation

Returns
Type Description
ObjectCollection

GetConvertedObjects()

Used to get an enumeration of the objects to which this object will be converted, before calling this function, the IsHaveToConvert function will be called

Declaration
public virtual IEnumerable<Base> GetConvertedObjects()
Returns
Type Description
System.Collections.Generic.IEnumerable<Base>

By default returns this object

Remarks

The functions IsHaveToConvert and GetConvertedObjects allow you to convert objects from one to another, for example the export will convert object before adding it to the file and convert recursive, i.e. If the new object has the ability to convert, it will be converted again but limit is 10 times. At the time of export it is called, only on objects inside the band, the child objects of converted object will be returned, and the child objects of old object will be ignored.

GetCustomScript()

Returns a custom code that will be added to the report script before report is run.

Declaration
public virtual string GetCustomScript()
Returns
Type Description
System.String

A custom script text, if any. Otherwise returns null.

Remarks

This method may return any valid code that may be inserted into the report script. Currently it is used in the TableObject to define the following script methods: Sum, Min, Max, Avg, Count.

Note: you must take into account the current script language - C# or VB.Net. You may check it via Report.ScriptLanguage property.

GetExpressions()

Gets all expressions contained in the object.

Declaration
public virtual string[] GetExpressions()
Returns
Type Description
System.String[]

Array of expressions or null if object contains no expressions.

Remarks

Do not call this method directly. You may override it if you are developing a new component for FastReport.

This method is called by FastReport each time before run a report. FastReport do this to collect all expressions and compile them. For example, GetExpressions method of the TextObject class parses the text and returns all expressions found in the text.

HasFlag(Flags)

Gets a value indicating whether the object has a specified flag in its Flags property.

Declaration
public bool HasFlag(Flags flag)
Parameters
Type Name Description
Flags flag

Flag to check.

Returns
Type Description
System.Boolean

true if Flags property contains specified flag.

HasParent(Base)

Gets a value indicating whether the object has the specified parent in its parent hierarhy.

Declaration
public bool HasParent(Base obj)
Parameters
Type Name Description
Base obj

Parent object to check.

Returns
Type Description
System.Boolean

Returns true if the object has given parent in its parent hierarhy.

HasRestriction(Restrictions)

Gets a value indicating whether the object has a specified restriction in its Restrictions property.

Declaration
public bool HasRestriction(Restrictions restriction)
Parameters
Type Name Description
Restrictions restriction

Restriction to check.

Returns
Type Description
System.Boolean

true if Restrictions property contains specified restriction.

InvokeEvent(String, Object)

Invokes script event.

Declaration
public void InvokeEvent(string name, object param)
Parameters
Type Name Description
System.String name

Name of the event to invoke.

System.Object param

Event parameters.

Remarks

Do not call this method directly. You should use it if you are developing a new component for FastReport.

Use this method to call an event handler that is located in the report's script.

Examples

Example of the OnBeforePrint method:

public void OnBeforePrint(EventArgs e)
{
if (BeforePrint != null)
BeforePrint(this, e);
InvokeEvent(BeforePrintEvent, e);
}

IsHaveToConvert(Object)

Used to get information of the need to convertation if the function returns true, then the GetConvertedObjects function is called

Declaration
public virtual bool IsHaveToConvert(object sender)
Parameters
Type Name Description
System.Object sender

The export or the object, that call this method

Returns
Type Description
System.Boolean

By default returns false

Remarks

The functions IsHaveToConvert and GetConvertedObjects allow you to convert objects from one to another, for example the export will convert object before adding it to the file and convert recursive, i.e. If the new object has the ability to convert, it will be converted again but limit is 10 times. At the time of export it is called, only on objects inside the band, the child objects of converted object will be returned, and the child objects of old object will be ignored.

OnAfterLoad()

Called after all report objects were loaded.

Declaration
public virtual void OnAfterLoad()
Remarks

Do not call this method directly. You may override it if you are developing a new component for FastReport.

Serialize(FRWriter)

Serializes the object.

Declaration
public virtual void Serialize(FRWriter writer)
Parameters
Type Name Description
FRWriter writer

Writer object.

Remarks

Do not call this method directly. You should override it if you are developing a new component for FastReport.

This method is called when the object needs to save the state. It may happen when:

  • saving the report to the file or stream;
  • saving the report to the designer's undo buffer;
  • assigning the object to another object using the Assign(Base) or AssignAll(Base) methods;
  • saving the object to the designer's clipboard;
  • saving the object to the preview (when run a report).

SetFlags(Flags, Boolean)

Set object's flags.

Declaration
public void SetFlags(Flags flags, bool value)
Parameters
Type Name Description
Flags flags

Flag to set.

System.Boolean value

true to set the flag, false to reset.

SetName(String)

Sets the object's name.

Declaration
public virtual void SetName(string value)
Parameters
Type Name Description
System.String value

New name.

Remarks

This method is for internal use only. It just sets a new name without any checks (unlike the Name property setter).

See Also
Name

SetParent(Base)

Sets the object's parent.

Declaration
public virtual void SetParent(Base value)
Parameters
Type Name Description
Base value

New parent.

Remarks

This method is for internal use only. You can use it if you are developing a new component for FastReport. Override it to perform some actions when the parent of an object is changing. This method checks that parent can contain a child.

Exceptions
Type Condition
ParentException

Parent object cannot contain this object.

SetParentCore(Base)

Sets the object's parent.

Declaration
public void SetParentCore(Base value)
Parameters
Type Name Description
Base value

New parent.

Remarks

This method is for internal use only. You can use it if you are developing a new component for FastReport. This method does not perform any checks, it just sets the new parent.

SetProp(Base, Base)

Helper method, helps to set a reference-type value to the property.

Declaration
protected void SetProp(Base prop, Base value)
Parameters
Type Name Description
Base prop

Old property value.

Base value

New property value.

Remarks

This method is used widely to set a new value to the property that references another FastReport object. Method deals with the Parent property.

Examples

This is example of the DataBand.Header property:

public DataHeaderBand Header
{
get { return FHeader; }
set
{
SetProp(FHeader, value);
FHeader = value;
}
}

SetReport(Report)

Sets the reference to a Report.

Declaration
public void SetReport(Report value)
Parameters
Type Name Description
Report value

Report to set.

Implements

IFRSerializable
Back to top Generated by DocFX