how to pass parameter in devexpress report

kashif picture kashif · Oct 3, 2012 · Viewed 19.8k times · Source

I am using Devexpress XtraReport in Windows application for reporting purpose. I have set a parameter param1 having string as type in my XtraReport1 and using following code to pass parameter.

private void button1_Click(object sender, EventArgs e)        
{
    XtraReport1 report = new XtraReport1();            
    report.Parameters["param1"].Value = "kashif";
    report.Print();
}

when I press button1 the following windows apperas and ask me for param1 values having already displayed "kashif" in it with button "Submit" and "Reset" My Problem is: I don't want this window to get opened when i Press button1 rather I want to pass directly "kashif" in it without prompting me for param1 value. testimage

Answer

Steve picture Steve · Oct 3, 2012

From their documentation here How To: Silently Pass a Parameter Value

Add a parameter to a report, set the parameter's Modifiers property to Public, and disable the parameter's Parameter.Visible property. When there are no visible parameters in a report, their values are passed "silently" (without exposing the Parameters UI to end-users).

private void button1_Click(object sender, EventArgs e) 
{
    // Create a report instance.
    XtraReport1 report = new XtraReport1();

    // Obtain a parameter, and set its value.
    report.parameter1.Value = 30;

    // Hide the Parameters UI from end-users.
    report.parameter1.Visible = false;

    // Show the report's print preview.
    report.ShowPreview();
}