Back to Devexpress

ParameterPanelFluentBuilder Class

xtrareports-devexpress-dot-xtrareports-dot-parameters.md

latest16.0 KB
Original Source

ParameterPanelFluentBuilder Class

Contains methods that allow you to customize the Parameters panel.

Namespace : DevExpress.XtraReports.Parameters

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
public class ParameterPanelFluentBuilder :
    ParameterPanelFluentBuilderBase
vb
Public Class ParameterPanelFluentBuilder
    Inherits ParameterPanelFluentBuilderBase

The following members return ParameterPanelFluentBuilder objects:

Remarks

You can unite report parameters into expandable groups, place parameters side-by-side, add separators, and more.

Default panelCustomized panel

Use the ParameterPanelFluentBuilder class as follows:

  1. Call the static Begin method and pass a report instance as a parameter.
  2. Call methods that customize the panel.
  3. Call the End method.
csharp
using DevExpress.XtraReports.Parameters;
// ...
ParameterPanelFluentBuilder.Begin(report)
// Customize the panel
.End();
vb
Imports DevExpress.XtraReports.Parameters
' ...
ParameterPanelFluentBuilder.Begin(report). ' Customize the panel
End()

Pass the report instance to the Document Viewer after you finish customization of the Parameters panel for this instance. See the following examples for details on how to complete this task for the WinForms and ASP.NET Core platforms:

View Example: Reporting for WinForms - Customize the Parameters Panel

View Example: Reporting for ASP.NET Core - Customize the Parameters Panel

Customize the “Parameters” Panel

A customized Parameters panel contains items of the following types:

Parameter itemCustomizes a report parameter.Group itemCreates and customizes a parameter group.Separator itemAdds a separator between groups and parameters.

There are two ways to create a new item:

  1. Call an item’s Begin method, customize the item, and call the item’s End method.

  2. Call an item’s AddItem method and pass a customization action as a parameter.

These ways have the same customization capabilities and differ only in syntax. In the following sections, we describe the second way in detail. For more examples on how to use the first way, refer to the description of the Begin / End methods:

Customize a Parameter

  1. Call the AddParameterItem method. This method accepts a report parameter or its name.
  2. Optional. Implement a customization action and pass this action to the AddParameterItem method as a second argument. The example below uses the WithLabelOrientation method to position the text label above the parameter editor.
csharp
using DevExpress.XtraReports.Parameters;
// ...
using Orientation = DevExpress.XtraReports.Parameters.Orientation;
// ...
ParameterPanelFluentBuilder.Begin(report)
    .AddParameterItem(report.Parameters[0], p => p
        .WithLabelOrientation(Orientation.Vertical))
.End();
vb
Imports DevExpress.XtraReports.Parameters
' ...
Imports Orientation = DevExpress.XtraReports.Parameters.Orientation
' ...
ParameterPanelFluentBuilder.Begin(report).
    AddParameterItem(report.Parameters(0), Function(p) p.
        WithLabelOrientation(Orientation.Vertical)).
End()
orientation = Horizontal (Default)orientation = Vertical

Call the AddParameterItem method only for those report parameters that you want to customize. The Parameters panel displays the remaining parameters at the end (with default settings).

Create and Customize a Group

Call the AddGroupItem method and implement a customization action. In this action, customize group appearance, add parameters, groups, and separators.

csharp
using DevExpress.XtraReports.Parameters;
// ...
ParameterPanelFluentBuilder.Begin(report)
    .AddParameterItem(report.Parameters[0])
    .AddGroupItem(g => g
        .WithTitle("Select a customer")
        .AddParameterItem(report.Parameters[1])
        .AddParameterItem(report.Parameters[2]))
.End();
vb
Imports DevExpress.XtraReports.Parameters
' ...
ParameterPanelFluentBuilder.Begin(report).
    AddParameterItem(report.Parameters(0)).
    AddGroupItem(Function(g) g.
        WithTitle("Select a customer").
        AddParameterItem(report.Parameters(1)).
        AddParameterItem(report.Parameters(2))).
End()
Default panelPanel with a group

The example above uses the WithTitle method to specify a group title. You can also use the following methods to configure a group:

Add a Separator

Call the AddSeparatorItem method to add a separator between parameters or groups.

csharp
using DevExpress.XtraReports.Parameters;
// ...
ParameterPanelFluentBuilder.Begin(report)
    .AddParameterItem(report.Parameters[0])
    .AddSeparatorItem()
    .AddParameterItem(report.Parameters[1])
.End();
vb
Imports DevExpress.XtraReports.Parameters
' ...
ParameterPanelFluentBuilder.Begin(report).
    AddParameterItem(report.Parameters(0)).
    AddSeparatorItem().
    AddParameterItem(report.Parameters(1)).
End()
Default panelPanel with a separator between parameters

Modify a Customized Panel

You can reconfigure items of a customized panel or remove some or all items to discard customization.

The following example removes a parameter and separator from a group and changes the label orientation of another parameter from the same group.

csharp
using DevExpress.XtraReports.Parameters;
// ...
using Orientation = DevExpress.XtraReports.Parameters.Orientation;
// ...
ParameterPanelFluentBuilder.Begin(report)
    .GetGroupItem(0)
        .RemoveParameterItem(report.Parameters[0])
        .RemoveSeparatorItem(0)
        .GetParameterItem(report.Parameters[1], p1 => p1
            .WithLabelOrientation(Orientation.Horizontal))
.End();
vb
Imports DevExpress.XtraReports.Parameters
' ...
Imports Orientation = DevExpress.XtraReports.Parameters.Orientation
' ...
ParameterPanelFluentBuilder.Begin(report).
    GetGroupItem(0).
        RemoveParameterItem(report.Parameters(0)).
        RemoveSeparatorItem(0).
        GetParameterItem(report.Parameters(1), Function(p1) p1.
            WithLabelOrientation(Orientation.Horizontal)).
End()
Initial panelModified panel

Refer to the descriptions of the following methods for more information:

Examples

Place Parameters Side-by-Side and Unite Them into Groups

csharp
using DevExpress.XtraReports.Parameters;
// ...
using Orientation = DevExpress.XtraReports.Parameters.Orientation;
// ...
ParameterPanelFluentBuilder.Begin(report)
    .AddGroupItem(g0 => g0
        .WithTitle("Select dates")
        .AddParameterItem(report.Parameters[0], p0 => p0
            .WithLabelOrientation(Orientation.Vertical)))
    .AddGroupItem(g1 => g1
        .WithTitle("Select a customer")
        .WithOrientation(Orientation.Horizontal)
        .WithShowExpandButton(true)
        .AddParameterItem(report.Parameters[1], p1 => p1
            .WithLabelOrientation(Orientation.Vertical))
        .AddSeparatorItem()
        .AddParameterItem(report.Parameters[2], p2 => p2
            .WithLabelOrientation(Orientation.Vertical)))
.End();
vb
Imports DevExpress.XtraReports.Parameters
' ...
Imports Orientation = DevExpress.XtraReports.Parameters.Orientation
' ...
ParameterPanelFluentBuilder.Begin(report).
    AddGroupItem(Function(g0) g0.
        WithTitle("Select dates").
        AddParameterItem(report.Parameters(0), Function(p0) p0.
            WithLabelOrientation(Orientation.Vertical))).
    AddGroupItem(Function(g1) g1.
        WithTitle("Select a customer").
        WithOrientation(Orientation.Horizontal).
        WithShowExpandButton(True).
        AddParameterItem(report.Parameters(1), Function(p1) p1.
            WithLabelOrientation(Orientation.Vertical)).
        AddSeparatorItem().
        AddParameterItem(report.Parameters(2), Function(p2) p2.
            WithLabelOrientation(Orientation.Vertical))).
End()
Default panelCustomized panel

Enable/Disable a Parameter Editor Based on a Value of Another Parameter

The following example specifies an expression for a parameter’s Enabled property to enable/disable the parameter’s editor based on a value of another parameter.

csharp
using DevExpress.XtraReports.Parameters;
// ...
using DevExpress.XtraReports.Expressions;
// ...
ParameterPanelFluentBuilder.Begin(report)
    .AddGroupItem(g0 => g0
        .WithTitle("Select dates")
        .AddParameterItem(report.Parameters[0]))
    .AddGroupItem(g1 => g1
        .WithTitle("Select a customer")
        .AddParameterItem(report.Parameters[1])
        .AddParameterItem(report.Parameters[2]))
.End();

report.Parameters["customer"].ExpressionBindings.Add(
    new BasicExpressionBinding() {
        PropertyName = "Enabled",
        Expression = "!IsNullOrEmpty(?company)",
});
vb
Imports DevExpress.XtraReports.Parameters
' ...
Imports DevExpress.XtraReports.Expressions
' ...
ParameterPanelFluentBuilder.Begin(report).
    AddGroupItem(Function(g0) g0.
        WithTitle("Select dates").
        AddParameterItem(report.Parameters(0))).
    AddGroupItem(Function(g1) g1.
        WithTitle("Select a customer").
        AddParameterItem(report.Parameters(1)).
        AddParameterItem(report.Parameters(2))).
End()

report.Parameters("customer").ExpressionBindings.Add(
    New BasicExpressionBinding() With {
        .PropertyName = "Enabled",
        .Expression = "!IsNullOrEmpty(?company)"
})

You can specify the same expression for the parameter’s Visible property to show/hide the parameter’s editor.

Inheritance

Object GroupItemFluentBuilder ParameterPanelFluentBuilderBase ParameterPanelFluentBuilder

See Also

ParameterPanelFluentBuilder Members

DevExpress.XtraReports.Parameters Namespace