Back to Devexpress

ParametersRequestEventArgs Class

corelibraries-devexpress-dot-xtrareports-dot-parameters-c0d071b3.md

latest6.8 KB
Original Source

ParametersRequestEventArgs Class

Provides data for the XtraReport.ParametersRequestBeforeShow and XtraReport.ParametersRequestSubmit events.

Namespace : DevExpress.XtraReports.Parameters

Assembly : DevExpress.Printing.v25.2.Core.dll

NuGet Package : DevExpress.Printing.Core

Declaration

csharp
public class ParametersRequestEventArgs :
    EventArgs
vb
Public Class ParametersRequestEventArgs
    Inherits EventArgs

ParametersRequestEventArgs is the data class for the following events:

LibraryRelated API Members
Cross-Platform Class LibraryRemoteDocumentSource.ParametersRequestBeforeShow
.NET Reporting ToolsXtraReport.ParametersRequestBeforeShow
XtraReport.ParametersRequestSubmit

Remarks

The XtraReport.ParametersRequestBeforeShow and XtraReport.ParametersRequestSubmit events occur before and after displaying the Parameters window or pane to an end-user. The ParametersRequestEventArgs class introduces the ParametersRequestEventArgs.ParametersInformation property, which provides access to the information about parameters. Each ParameterInfo class contains information about the ParameterInfo.Parameter itself, as well as about the ParameterInfo.Editor which is used to enter the parameter’s value.

Note

ParametersRequestEventArgs objects are automatically created, initialized and passed to the XtraReport.ParametersRequestBeforeShow and XtraReport.ParametersRequestSubmit event handlers.

Example

This example illustrates how to change the standard editor displayed in Print Preview for a report parameter with a custom one.

Tip

Print Preview displays default value editors according to report parameter types (their Parameter.Type property values).

A custom editor specified in this example is used only for demonstration purposes, because a LookUpEdit is automatically assigned to parameters for which the ReportParameter.LookUpValues property is specified.

Handle the XtraReport.ParametersRequestBeforeShow event and assign a custom editor to the ParameterInfo.Editor property of the ParameterInfo object stored in the ParametersRequestEventArgs.ParametersInformation collection to provide a custom report parameter editor in a WinForms application.

csharp
using System;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.Parameters;
// ...

private void XtraReport1_ParametersRequestBeforeShow(object sender, ParametersRequestEventArgs e) {
    CategoriesDataSet dataSet = new CategoriesDataSet();
    CategoriesDataSetTableAdapters.CategoriesTableAdapter adapter = 
        new CategoriesDataSetTableAdapters.CategoriesTableAdapter();
    adapter.Fill(dataSet.Categories);

    foreach (ParameterInfo info in e.ParametersInformation) {
        if (info.Parameter.Name == "parameter1") {
            LookUpEdit lookUpEdit = new LookUpEdit();
            lookUpEdit.Properties.DataSource = dataSet.Categories;
            lookUpEdit.Properties.DisplayMember = "CategoryName";
            lookUpEdit.Properties.ValueMember = "CategoryID";
            lookUpEdit.Properties.Columns.Add(new 
                LookUpColumnInfo("CategoryName", 0, "Category Name"));
            info.Editor = lookUpEdit;
        }
    }
}
vb
Imports System
Imports DevExpress.XtraEditors
Imports DevExpress.XtraEditors.Controls
Imports DevExpress.XtraReports.UI
Imports DevExpress.XtraReports.Parameters
' ...

Private Sub XtraReport1_ParametersRequestBeforeShow(sender As Object, e As ParametersRequestEventArgs)
    Dim DataSet As New CategoriesDataSet()
    Dim Adapter As New CategoriesDataSetTableAdapters.CategoriesTableAdapter()
    Adapter.Fill(DataSet.Categories)

    Dim Info As ParameterInfo

    For Each Info In e.ParametersInformation
        If Info.Parameter.Name = "Parameter1" Then
            Dim LookUpEdit As New LookUpEdit()
            LookUpEdit.Properties.DataSource = DataSet.Categories
            LookUpEdit.Properties.DisplayMember = "CategoryName"
            LookUpEdit.Properties.ValueMember = "CategoryID"
            LookUpEdit.Properties.Columns.Add(New _
                LookUpColumnInfo("CategoryName", 0, "Category Name"))
            Info.Editor = LookUpEdit
        End If
    Next Info
End Sub

Inheritance

Object EventArgs ParametersRequestEventArgs

See Also

ParametersRequestEventArgs Members

Use Report Parameters

DevExpress.XtraReports.Parameters Namespace