xtrareports-devexpress-dot-xtrareports-dot-ui-dot-bandfactory-dot-createinstance-x28-devexpress-dot-xtrareports-dot-ui-dot-bandkind-x29.md
Creates a report band instance.
Namespace : DevExpress.XtraReports.UI
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
public virtual Band CreateInstance(
BandKind bandKind
)
Public Overridable Function CreateInstance(
bandKind As BandKind
) As Band
| Name | Type | Description |
|---|---|---|
| bandKind | BandKind |
A BandKind enumeration value.
|
| Type | Description |
|---|---|
| Band |
A descendant of the Band class.
|
The following example illustrates how to use the BandFactory class for overriding the default behavior for adding new Page Headers to a report.
using DevExpress.XtraReports.UI;
// ...
public class MyCustomPageHeaderBand : PageHeaderBand {
public string MyCustomBandProperty { get; set; }
}
public class MyCustomBandFactory : BandFactory {
public override Band CreateInstance(BandKind bandKind) {
if (bandKind == BandKind.PageHeader)
return new MyCustomPageHeaderBand();
return base.CreateInstance(bandKind);
}
}
Imports DevExpress.XtraReports.UI
' ...
Public Class MyCustomPageHeaderBand
Inherits PageHeaderBand
Public Property MyCustomBandProperty() As String
Get
Return m_MyCustomBandProperty
End Get
Set
m_MyCustomBandProperty = Value
End Set
End Property
Private m_MyCustomBandProperty As String
End Class
Public Class MyCustomBandFactory
Inherits BandFactory
Public Overrides Function CreateInstance(MyBandKind As BandKind) As Band
If MyBandKind = BandKind.PageHeader Then
Return New MyCustomPageHeaderBand()
End If
Return MyBase.CreateInstance(MyBandKind)
End Function
End Class
To register a custom band factory, assign it to the protected static bandFactory property of the XtraReportBase class.
using DevExpress.XtraReports.UI;
// ...
public class XtraReport1 : XtraReport {
public XtraReport1() {
InitializeComponent();
bandFactory = new MyCustomBandFactory();
}
}
Imports DevExpress.XtraReports.UI
' ...
Public Class XtraReport1
Inherits XtraReport
Public Sub New()
InitializeComponent()
bandFactory = New MyCustomBandFactory()
End Sub
End Class
See Also