Class DataBand
This class represents the Data band.
Inheritance
Inherited Members
Namespace: FastReport
Assembly: FastReport.Base.dll
Syntax
public class DataBand : BandBase, IFRSerializable, IParent
Remarks
Use the DataSource property to connect the band to a datasource. Set the Filter property if you want to filter data rows. The Sort property can be used to sort data rows.
Constructors
DataBand()
Initializes a new instance of the DataBand class.
Declaration
public DataBand()
Properties
Bands
Gets a collection of detail bands.
Declaration
public BandCollection Bands { get; }
Property Value
Type | Description |
---|---|
BandCollection |
CollectChildRows
Gets or sets a value indicating that the databand should collect child data rows.
Declaration
public bool CollectChildRows { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
This property determines how the master-detail report is printed. Default behavior is:
MasterData row1
-- DetailData row1
-- DetailData row2
-- DetailData row3
MasterData row2
-- DetailData row1
-- DetailData row2
When you set this property to true, the master databand will collect all child data rows under a single master data row:
MasterData row1
-- DetailData row1
-- DetailData row2
-- DetailData row3
-- DetailData row4
-- DetailData row5
Columns
Gets the band columns.
Declaration
public BandColumns Columns { get; }
Property Value
Type | Description |
---|---|
BandColumns |
DataSource
Gets or sets a data source. Please note: data source have to be enabled.
Declaration
public DataSourceBase DataSource { get; set; }
Property Value
Type | Description |
---|---|
DataSourceBase |
Filter
Gets the row filter expression.
Declaration
public string Filter { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
This property can contain any valid boolean expression. If the expression returns false, the corresponding data row will not be printed.
Footer
Gets or sets a footer band.
Declaration
public DataFooterBand Footer { get; set; }
Property Value
Type | Description |
---|---|
DataFooterBand |
Header
Gets or sets a header band.
Declaration
public DataHeaderBand Header { get; set; }
Property Value
Type | Description |
---|---|
DataHeaderBand |
IdColumn
Gets or sets the key column that identifies the data row.
Declaration
public string IdColumn { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
This property is used when printing a hierarchic list.
To print the hierarchic list, you have to setup three properties: IdColumn, ParentIdColumn and Indent. First two properties are used to identify the data row and its parent; the Indent property specifies the indent that will be used to shift the databand according to its hierarchy level.
When printing hierarchy, FastReport shifts the band to the right (by value specified in the Indent property), and also decreases the width of the band by the same value. You may use the Anchor property of the objects on a band to indicate whether the object should move with the band, or stay on its original position, or shrink.
Indent
Gets or sets the indent that will be used to shift the databand according to its hierarchy level.
Declaration
public float Indent { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
Remarks
This property is used when printing a hierarchic list. See description of the IdColumn property for more details.
KeepDetail
Gets or sets a value indicating that the band should be printed together with all its detail rows.
Declaration
public bool KeepDetail { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
KeepTogether
Gets or sets a value indicating that all band rows should be printed together on one page.
Declaration
public bool KeepTogether { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
MaxRows
Limits the maximum number of rows in a datasource. 0 means no limit.
Declaration
public int MaxRows { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
ParentIdColumn
Gets or sets the column that identifies the parent data row.
Declaration
public string ParentIdColumn { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
This property is used when printing a hierarchic list. See description of the IdColumn property for more details.
PrintIfDatasourceEmpty
Gets or sets a value that determines whether to print a band if its datasource is empty.
Declaration
public bool PrintIfDatasourceEmpty { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
PrintIfDetailEmpty
Gets or sets a value that determines whether to print a band if all its detail rows are empty.
Declaration
public bool PrintIfDetailEmpty { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Relation
Gets or sets a relation used to establish a master-detail relationship between this band and its parent.
Declaration
public Relation Relation { get; set; }
Property Value
Type | Description |
---|---|
Relation |
Remarks
Use this property if there are several relations exist between two data sources. If there is only one relation (in most cases it is), you can leave this property empty.
ResetPageNumber
Gets or sets a value that determines whether to reset the page numbers when this band starts print.
Declaration
public bool ResetPageNumber { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
Typically you should set the StartNewPage property to true as well.
RowCount
Gets or sets a number of rows in the virtual data source.
Declaration
public int RowCount { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
Use this property if your data band is not connected to any data source. In this case the virtual data source with the specified number of rows will be used.
Sort
Gets the collection of sort conditions.
Declaration
public SortCollection Sort { get; }
Property Value
Type | Description |
---|---|
SortCollection |
Methods
AddChild(Base)
Adds a child object to this object's childs.
Declaration
public override void AddChild(Base child)
Parameters
Type | Name | Description |
---|---|---|
Base | child | Object to add. |
Overrides
Assign(Base)
Copies the contents of another, similar object.
Declaration
public override void Assign(Base source)
Parameters
Type | Name | Description |
---|---|---|
Base | source | Source object to copy the contents from. |
Overrides
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 method.
See Also
CanContain(Base)
Gets a value indicating that this object can contain the specified child object.
Declaration
public override bool CanContain(Base child)
Parameters
Type | Name | Description |
---|---|---|
Base | child | Child object. |
Returns
Type | Description |
---|---|
System.Boolean | true if this object can contain the specified child object; otherwise, false. |
Overrides
DeserializeSubItems(FRReader)
Deserializes nested object properties.
Declaration
protected override void DeserializeSubItems(FRReader reader)
Parameters
Type | Name | Description |
---|---|---|
FRReader | reader | Reader object. |
Overrides
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.
GetChildObjects(ObjectCollection)
Gets a list of child objects.
Declaration
public override void GetChildObjects(ObjectCollection list)
Parameters
Type | Name | Description |
---|---|---|
ObjectCollection | list | List to fill with values. |
Overrides
GetChildOrder(Base)
Returns z-order of the specified child object.
Declaration
public override int GetChildOrder(Base child)
Parameters
Type | Name | Description |
---|---|---|
Base | child | Child object. |
Returns
Type | Description |
---|---|
System.Int32 | Z-order of the specified object. |
Overrides
Remarks
This method must return the index of a specified child object in the internal child list.
GetExpressions()
Gets all expressions contained in the object.
Declaration
public override string[] GetExpressions()
Returns
Type | Description |
---|---|
System.String[] | Array of expressions or null if object contains no expressions. |
Overrides
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.
InitDataSource()
Initializes the data source connected to this band.
Declaration
public void InitDataSource()
InitializeComponent()
Initializes the object before running a report.
Declaration
public override void InitializeComponent()
Overrides
Remarks
This method is used by the report engine, do not call it directly.
RemoveChild(Base)
Removes a specified object from this object's childs.
Declaration
public override void RemoveChild(Base child)
Parameters
Type | Name | Description |
---|---|---|
Base | child |
Overrides
Serialize(FRWriter)
Serializes the object.
Declaration
public override void Serialize(FRWriter writer)
Parameters
Type | Name | Description |
---|---|---|
FRWriter | writer | Writer object. |
Overrides
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 methods;
- saving the object to the designer's clipboard;
- saving the object to the preview (when run a report).
SetChildOrder(Base, Int32)
Sets the z-order of the specified object.
Declaration
public override void SetChildOrder(Base child, int order)
Parameters
Type | Name | Description |
---|---|---|
Base | child | Child object. |
System.Int32 | order | New Z-order. |
Overrides
Remarks
This method must place the specified child object at the specified position in the internal child list.