ReportParameterInfo クラス

レポート パラメーターに関する情報をカプセル化します。

継承階層

System.Object
  Microsoft.Reporting.WinForms.ReportParameterInfo

名前空間:  Microsoft.Reporting.WinForms
アセンブリ:  Microsoft.ReportViewer.WinForms (Microsoft.ReportViewer.WinForms.dll)

構文

'宣言
Public NotInheritable Class ReportParameterInfo
'使用
Dim instance As ReportParameterInfo
public sealed class ReportParameterInfo
public ref class ReportParameterInfo sealed
[<SealedAttribute>]
type ReportParameterInfo =  class end
public final class ReportParameterInfo

ReportParameterInfo 型は、以下のメンバーを公開しています。

プロパティ

  名前 説明
パブリック プロパティ AllowBlank パラメーターに対して空の文字列が有効な値であるかどうかを指定します。読み取り専用。
パブリック プロパティ AreDefaultValuesQueryBased パラメーターの既定値がクエリに基づいているかどうかを示します。読み取り専用。
パブリック プロパティ AreValidValuesQueryBased パラメーターの有効な値がクエリに基づいているかどうかを示します。読み取り専用。
パブリック プロパティ DataType パラメーターのデータ型を取得します。読み取り専用。
パブリック プロパティ Dependencies クエリで追加のパラメーター値を取得するために使用される値を持つパラメーターの一覧を取得します。読み取り専用。
パブリック プロパティ Dependents このパラメーターの値をクエリでパラメーターとして使用して ValidValues や DefaultValues() を取得するパラメーターの一覧。
パブリック プロパティ ErrorMessage パラメーターが検証に失敗したときに返されるエラー メッセージを取得します。読み取り専用。
パブリック プロパティ IsQueryParameter 外部データ ソースへのクエリで使用されるパラメーターかどうかを示します。読み取り専用です。
パブリック プロパティ MultiValue 複数の値を持つパラメーターが有効かどうかを示します。読み取り専用です。
パブリック プロパティ Name パラメーターの名前を取得します。読み取り専用です。
パブリック プロパティ Nullable パラメーターの値として nullNULL 参照 (Visual Basic では Nothing) が有効かどうかを示します。読み取り専用です。
パブリック プロパティ Prompt ユーザーにパラメーター値の入力を求めるテキストです。
パブリック プロパティ PromptUser ユーザーにパラメーター値の入力を求めるかどうかを示します。
パブリック プロパティ State パラメーターの状態を説明します。読み取り専用です。
パブリック プロパティ ValidValues パラメーターに使用できる有効な値を取得します。読み取り専用です。
パブリック プロパティ Values パラメーターの値を取得します。
パブリック プロパティ Visible パラメーターをユーザー インターフェイスに表示するかどうかを決定します。

Top

メソッド

  名前 説明
パブリック メソッド Equals (Object から継承されています。)
プロテクト メソッド Finalize (Object から継承されています。)
パブリック メソッド GetHashCode (Object から継承されています。)
パブリック メソッド GetType (Object から継承されています。)
プロテクト メソッド MemberwiseClone (Object から継承されています。)
パブリック メソッド ToString (Object から継承されています。)

Top

説明

ReportParameterInfo クラスは、実行時にレポートのパラメーター要件を判断するときに使用できます。

使用例

次のコード例では、WinForms アプリケーションに ReportViewer コントロールがあることを前提としています。このコードでは、サンプル レポートがレポート サーバーからプログラムによって読み込まれ、ServerReport オブジェクトの ReportParameterInfoCollection プロパティにカプセル化されているパラメーターが繰り返し処理されて、各レポート パラメーターに関する情報が表示されます。

[C#]

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

namespace ParamSample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            // Set Processing Mode
            reportViewer1.ProcessingMode = ProcessingMode.Remote;

            // Set report server and report path
            reportViewer1.ServerReport.ReportServerUrl = new
            Uri("https://localhost/reportserver");
            reportViewer1.ServerReport.ReportPath = 
               "/AdventureWorks Sample Reports/Employee Sales Summary";

            // Display the parameters for this report
            DumpParameterInfo(reportViewer1.ServerReport);

            // Set the parameters for this report
            List<ReportParameter> paramList = new List<ReportParameter>();

            paramList.Add(new ReportParameter("EmpID", "288", false));
            paramList.Add(new ReportParameter("ReportMonth", "12", false));
            paramList.Add(
               new ReportParameter("ReportYear", "2003", false));

            this.reportViewer1.ServerReport.SetParameters(paramList);

            // Process and render the report
            reportViewer1.RefreshReport();


        }

        public void DumpParameterInfo(ServerReport sReport)
        {
            ReportParameterInfoCollection pInfo = sReport.GetParameters();

            if (pInfo.Count == 0)
            {
                Console.WriteLine("<No parameters are defined for this report>");
            }
            else
            {
                Console.WriteLine("===========================================================================");
                Console.WriteLine("Parameter Info for " + sReport.ReportPath);

                foreach (ReportParameterInfo p in pInfo)
                {
                    Console.WriteLine("----------------------------------------------------------------------");
                    Console.WriteLine("Parameter Name: {0}", p.Name);
                    Console.WriteLine("Data Type: {0}", p.DataType);
                    Console.WriteLine("State: {0}", p.State);
                    Console.WriteLine("Allow Blank? {0}", p.AllowBlank);
                    Console.WriteLine("Nullable? {0}", p.Nullable);
                    Console.WriteLine("Prompt User? {0}", p.PromptUser);
                    Console.WriteLine("User Prompt: {0}", p.Prompt);
                    Console.WriteLine("Visible? {0}", p.Visible);
                    Console.WriteLine("MultiValued? {0}", p.MultiValue);
                    Console.WriteLine("Default values query-based? {0}", p.AreDefaultValuesQueryBased);
                    Console.Write("Default value(s): ");

                    // Show a list of default values for the report params
                    IList<string> dvList = p.Values;
                    int t;

                    if (dvList.Count != 0)
                    {

                        t = 1;

                        foreach (string dv in dvList)
                        {
                            if (t != dvList.Count)
                            {
                                t++;
                                Console.Write(dv + ", ");
                            }
                            else
                            {
                                if (t == 1)
                                    Console.WriteLine(dv);
                                else
                                    Console.WriteLine("or " + dv);
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("<no default values defined>");
                    }

                    Console.WriteLine("Valid values query based? {0}", p.AreValidValuesQueryBased);
                    Console.Write("Valid values: ");

                    // Show a list of valid values for the report params

                    IList<ValidValue> vvList = p.ValidValues;

                    if (vvList != null)
                    {

                        t = 1;

                        foreach (ValidValue vv in vvList)
                        {
                            if (t != vvList.Count)
                            {
                                t++;
                                Console.Write(vv.Value + ", ");
                            }
                            else
                            {
                                if (t == 1)
                                    Console.WriteLine(vv.Value);
                                else
                                    Console.WriteLine("or " + vv.Value);
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("<no valid values defined>");
                    }

                    Console.Write("Dependent parameters: ");

                    ReportParameterInfoCollection dpInfo = p.Dependencies;
                    t = 1;

                    if (dpInfo.Count != 0)
                    {

                        foreach (ReportParameterInfo dp in dpInfo)
                        {
                            if (t != dpInfo.Count)
                            {
                                t++;
                                Console.Write(dp.Name + ", ");
                            }
                            else
                            {
                                if (t == 1)
                                    Console.WriteLine(dp.Name);
                                else
                                    Console.WriteLine("or " + dp.Name);
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("<no dependent parameters defined>");
                    }
                    
                }
                
            }
            Console.WriteLine("----------------------------------------------------------------------");
        }
    }
}

スレッド セーフ

この型の public static (Visual Basic では Shared) のメンバーはすべて、スレッド セーフです。インスタンス メンバーの場合は、スレッド セーフであるとは限りません。

関連項目

参照

Microsoft.Reporting.WinForms 名前空間