Back to Devexpress

XtraReport.FillEmptySpace Event

xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xtrareport-e77d36cc.md

latest4.8 KB
Original Source

XtraReport.FillEmptySpace Event

Fires after page rendering if a gap remains between the rendered bands.

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
public virtual event BandEventHandler FillEmptySpace
vb
Public Overridable Event FillEmptySpace As BandEventHandler

Event Data

The FillEmptySpace event's data class is BandEventArgs. The following properties provide information specific to this event:

PropertyDescription
BandGets a band, for which an event has occurred.

Remarks

Handle this event to get rid of the empty space on each page by filling it with the desired color or text, or by drawing special symbols.

Use the DetailBand.FillEmptySpace instead of this event to fill the empty space between the DetailBand and the next band/page bottom.

Example

The following code draws a Z mark that fills the blank area across a report page, by handing the XtraReport.FillEmptySpace event.

csharp
using System.Drawing;
using DevExpress.XtraPrinting;
using DevExpress.XtraPrinting.Drawing;
using DevExpress.XtraReports.UI;
// ...

private void XtraReport1_FillEmptySpace(object sender, BandEventArgs e) {
    if(!drawZBelowTheTable) {
        FillEmptySpace -= report_FillEmptySpace;
        return;
    }
    int bandHeight = GraphicsUnitConverter.Convert(e.Band.Height, ReportUnit.ToDpi(), ReportUnit.HundredthsOfAnInch.ToDpi());
    if(bandHeight <= 30)
        return;    

    // Obtain the empty space dimensions.
    Size size = new Size(612, bandHeight - 30);
    Size sizeInPixels = XRConvert.Convert(size, GraphicsDpi.HundredthsOfAnInch, GraphicsDpi.Pixel);

    // Draw a Z-mark bitmap.
    Bitmap zBitmap = new Bitmap(sizeInPixels.Width, sizeInPixels.Height);
    Graphics gr = Graphics.FromImage(zBitmap);
    using(Pen pen = new Pen(Color.FromArgb(205, 205, 205), 4)) {
        Point[] points = new Point[] { 
            new Point(0, 4),
            new Point(sizeInPixels.Width, 4),
            new Point(0, sizeInPixels.Height - 4),
            new Point(sizeInPixels.Width, sizeInPixels.Height - 4)
        };
        gr.DrawLines(pen, points);
    }

    // Create a picture control, place it within the report
    // and assign the bitmap to the control.
    XRPictureBox pictureBox = new XRPictureBox();
    pictureBox.BackColor = Color.Transparent;
    pictureBox.Size = size;
    pictureBox.Location = new Point(19, 15);
    pictureBox.ImageSource = new ImageSource(zBitmap);
    e.Band.Controls.Add(pictureBox);
}
vb
Imports System.Drawing
Imports DevExpress.XtraPrinting
DevExpress.XtraPrinting.Drawing
Imports DevExpress.XtraReports.UI
' ...

Private Sub XtraReport1_FillEmptySpace(ByVal sender As Object, _ 
ByVal e As BandEventArgs)
If Not drawZBelowTheTable Then
    FillEmptySpace -= report_FillEmptySpace
    Return
End If
Dim bandHeight As Integer = GraphicsUnitConverter.Convert(e.Band.Height, ReportUnit.ToDpi(), ReportUnit.HundredthsOfAnInch.ToDpi())
If bandHeight <= 30 Then
    Return
End If

   ' Obtain the empty space dimensions.
Dim size As New Size(612, bandHeight - 30)
Dim sizeInPixels As Size = XRConvert.Convert(size, GraphicsDpi.HundredthsOfAnInch, GraphicsDpi.Pixel)

' Draw a Z-mark bitmap.
Dim zBitmap As New Bitmap(sizeInPixels.Width, sizeInPixels.Height)
Dim gr As Graphics = Graphics.FromImage(zBitmap)
Using pen As New Pen(Color.FromArgb(205, 205, 205), 4)
    Dim points As Point() = New Point() {New Point(0, 4), New Point(sizeInPixels.Width, 4), New Point(0, sizeInPixels.Height - 4), New Point(sizeInPixels.Width, sizeInPixels.Height - 4)}
    gr.DrawLines(pen, points)
End Using

' Create a picture control, place it within the report
' and assign the bitmap to the control.
Dim pictureBox As New XRPictureBox()
pictureBox.BackColor = Color.Transparent
pictureBox.Size = size
pictureBox.Location = New Point(19, 15)
pictureBox.ImageSource = New ImageSource(zBitmap)
e.Band.Controls.Add(pictureBox)
End Sub

See Also

XtraReport Class

XtraReport Members

DevExpress.XtraReports.UI Namespace