c sharp crystal report

I use crystal report to printout the report from database table directly by using parameter field.
I build a parameter field namely "CurrentCity" with type string and I drag the parameter field to my crystal report form in user form.
And I write the code below to take the value from parameter field to appear in report. The code work well with parameter field...
But I have a problem to close the edit parameter field in which appear all the time with the application appear and force me to input the value.
My application the input is from database directly so I do not want to use the edit parameter field. But the problem is I do not  know the command to inactive the edit parameter field panel. Shall any body help me. I need help.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.Shared;
namespace ParameterDiscrete
    public partial class Form1 : Form
        public Form1()
        private void cmdView_Click(object sender, EventArgs e)
            ParameterFields pfs =new ParameterFields();
            ParameterField pf =new ParameterField();
            ParameterDiscreteValue pdv1 = new ParameterDiscreteValue();
            ParameterDiscreteValue pdv2 =new ParameterDiscreteValue();
            if ((txtCity1.Text == "") && (txtCity2.Text == "")) 
7H-@!7- !!!", "%2##'*-", MessageBoxButtons.OK, MessageBoxIcon.Information);
            pf.ParameterFieldName = "CurrentCity";
            pdv1.Value = txtCity1.Text;
            pdv2.Value = txtCity2.Text;
            crvDisplay.ParameterFieldInfo = pfs;
            crvDisplay.ReportSource = new CustomersByCity();

Open in new window

Who is Participating?
mlmccConnect With a Mentor Commented:
Don't refresh the report at the end.
That clears all parameter values.

Richard QuadlingConnect With a Mentor Senior Software DeveloperCommented:
I don't know C#, but in PHP, I use the SetCurrentValue method on the parameter.

I have added the parameter to the report manually, so it is always available.

// Iterate the parameters and set them to the required values shown above.
foreach($o_CrReport->ParameterFields as $i_Parameter => $o_Parameter)
      $o_Parameter->SetCurrentValue($a_ParametersToSupply[$o_Parameter->Name], $o_Parameter->ValueType);

$a_ParametersToSupply[$o_Parameter->Name] is a list of params in a name/value pair.

Adding the param at runtime seems odd. How do you use the param in the report? Just asking for it, doesn't mean it is linked to the select expert or anything.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.