Back to Devexpress

Multi-Value Report Parameters

xtrareports-9998-feature-guide-to-devexpress-reports-use-report-parameters-multi-value-report-parameters.md

latest11.8 KB
Original Source

Multi-Value Report Parameters

  • Feb 18, 2026
  • 6 minutes to read

This document describes how to create a multi-value parameter and use this parameter to filter report data. For information on how to use a multi-value parameter in expressions and queries, refer to the following help topic: Use Query Parameters.

Create a Multi-Value Parameter in the Report Designer

Follow the steps below to create a multi-value parameter in the Visual Studio Report Designer:

  1. Create a report parameter and enable the Allow multiple values option (which corresponds to the parameter’s MultiValue property).

  2. Specify a list of predefined values for the parameter. You can create a static list of values or load values from a data source. Refer to the following topics for instructions on how to do it:

Create a Multi-Value Parameter in Code

  1. Create a StaticListLookUpSettings or DynamicListLookUpSettings class instance and configure it with a set of predefined parameter values.
  2. Assign the instance to the parameter’s ValueSourceSettings property.
  3. Enable the parameter’s MultiValue property.

When you process multi-value report parameters in code, you may need to access the list of all parameter values. Refer to the LookUpHelper class description for details on how you can complete this task.

Example

View Example: Create a Multi-Value Report Parameter

The following example demonstrates how to create a multi-value report parameter and specify a list of predefined values loaded for the report’s data source.

csharp
using System;
using System.IO;
using System.Windows.Forms;
using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Sql;
using DevExpress.XtraReports.Parameters;
using DevExpress.XtraReports.UI;
// ...
            // Create a report instance.
            var report = new XtraReport1();
            ConfigureDataSource(ref report);

            // Create a multi-value parameter and specify its properties. 
            Parameter parameter1 = new Parameter();
            parameter1.Name = "CategoryIDs";
            parameter1.Type = typeof(System.Int32);
            parameter1.MultiValue = true;
            parameter1.Description = "Categories: ";

            // Create a DynamicListLookUpSettings instance and set up its properties.
            DynamicListLookUpSettings lookupSettings = new DynamicListLookUpSettings();
            lookupSettings.DataSource = report.DataSource;
            lookupSettings.DataMember = "Categories";
            lookupSettings.DisplayMember = "CategoryName";
            lookupSettings.ValueMember = "CategoryId";

            // Assign the settings to the parameter's LookUpSettings property.
            parameter1.LookUpSettings = lookupSettings;

            // Set the parameter's Visible and SelectAllValues properties to true to
            // make the parameter visible in the Parameters Panel and select all
            // values as defaults.
            parameter1.Visible = true;
            parameter1.SelectAllValues = true;

            // Add the parameter to the report's Parameters collection.
            report.Parameters.Add(parameter1);

            // Use the parameter to filter the report's data.
            report.FilterString = "CategoryID in (?CategoryIDs)";
vb
Imports System
Imports System.Collections.Generic
Imports System.IO
Imports System.Linq
Imports System.Threading.Tasks
Imports System.Windows.Forms
Imports DevExpress.DataAccess.ConnectionParameters
Imports DevExpress.DataAccess.Sql
Imports DevExpress.XtraReports.Parameters
Imports DevExpress.XtraReports.UI
' ...
            ' Create a report instance.
            Dim report = New XtraReport1()
            ConfigureDataSource(report)

            ' Create a multi-value parameter and specify its properties. 
            Dim parameter1 As New Parameter With {
                .Name = "CategoryIDs",
                .Type = GetType(System.Int32),
                .MultiValue = True,
                .Description = "Categories: "
            }

            ' Create a DynamicListLookUpSettings instance and set up its properties.
            Dim lookupSettings As New DynamicListLookUpSettings With {
                .DataSource = report.DataSource,
                .DataMember = "Categories",
                .DisplayMember = "CategoryName",
                .ValueMember = "CategoryId"
            }

            ' Assign the settings to the parameter's LookUpSettings property.
            parameter1.LookUpSettings = lookupSettings

            ' Set the parameter's Visible and SelectAllValues properties to true to
            ' make the parameter visible in the Parameters Panel and select all
            ' values as defaults.
            parameter1.Visible = True
            parameter1.SelectAllValues = True

            ' Add the parameter to the report's Parameters collection.
            report.Parameters.Add(parameter1)

            ' Use the parameter to filter the report's data.
            report.FilterString = "CategoryID in (?CategoryIDs)"

Filter a Report’s Data by a Multi-Value Parameter

To filter a report’s data by a multi-value parameter, use the Is any of operator for this parameter in the report’s filter string:

To filter the report’s data in code, assign a filter condition to the report’s FilterString property:

csharp
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.Parameters;

// ...
// Create a multi-value parameter and specify its properties.
Parameter parameter1 = new Parameter(); 
parameter1.Name = "CategoryIDs";
parameter1.MultiValue = true;

// ...

// Specify a filter condition for the report's data. 
report.FilterString = "CategoryName in (?CategoryIDs)";
vb
Imports DevExpress.XtraReports.UI
Imports DevExpress.XtraReports.Parameters

' ...
' Create a multi-value parameter and specify its properties.
Private parameter1 As New Parameter()
parameter1.Name = "CategoryIDs"
parameter1.MultiValue = True

' ...

' Specify a filter condition for the report's data. 
report.FilterString = "CategoryName in (?CategoryIDs)"

The filtered report is displayed after you specify parameter values.

Specify Default Values for a Multi-Value Parameter

Design Time

A multi-value parameter’s default values are selected automatically when you open a report’s Print Preview :

Use one of the following methods to specify default values:

  • Assign an array of values to the Default Value option (which corresponds to a parameter’s Value property). You must enter values separated with the list delimiter defined for the current culture. This means that values may not always be separated by commas, but by semicolons and other characters depending on the current culture.

  • Enable the Select all values property to populate the parameter value with all items from the parameter’s value source (static or dynamic).

Tip

Disable a report’s RequestParameters property to avoid the Waiting for parameter values message on the report’s Print Preview and display the report with default parameter values.

Runtime

The following example illustrates how to specify default values for a multi-value report parameter in code:

csharp
using System;
using System.Windows.Forms;
using DevExpress.XtraReports.Parameters;
// ...

// Create a report instance.
var report = new XtraReport1();

// Create a multi-value parameter.
var parameter = new Parameter() {
    Name = "number",
    MultiValue = true,
    Type = typeof(System.Int32),
};

// Create a static list of predefined values for the parameter.
var sourceSettings = new StaticListLookUpSettings();
sourceSettings.LookUpValues.Add(new LookUpValue(1, "One"));
sourceSettings.LookUpValues.Add(new LookUpValue(2, "Two"));
sourceSettings.LookUpValues.Add(new LookUpValue(3, "Three"));
parameter.ValueSourceSettings = sourceSettings;

// Specify the parameter's default values.
parameter.Value = new int[] { 1, 3 };

// Add the parameter to the report's Parameters collection.
report.Parameters.Add(parameter);
vb
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraReports.Parameters
' ...

' Create a report instance.
Private report = New XtraReport1()

' Create a multi-value parameter.
Private parameter = New Parameter() With {.Name = "number", .MultiValue = True, .Type = GetType(System.Int32)}

' Create a static list of predefined values for the parameter.
Private sourceSettings = New StaticListLookUpSettings()
sourceSettings.LookUpValues.Add(New LookUpValue(1, "One"))
sourceSettings.LookUpValues.Add(New LookUpValue(2, "Two"))
sourceSettings.LookUpValues.Add(New LookUpValue(3, "Three"))
parameter.ValueSourceSettings = sourceSettings

' Specify the parameter's default values.
parameter.Value = New Integer() { 1, 3 }

' Add the parameter to the report's Parameters collection.
report.Parameters.Add(parameter)

Note

Ensure that the type of default values match the parameter type when you specify these values for the parameter.

Create an Optional Multi-Value Parameter

Optional parameters allow you to filter report data only if parameter values are specified. Otherwise, if parameter values are not set, the parameter is ignored.

Do the following to make a multi-value parameter optional.

  1. Create a multi-value report parameter and specify its Allow null value, Default Value, and Select all values options as shown below:

  2. Disable the report’s RequestParameters property.

  3. Assign the following filter condition to the report’s filter string: