?
Solved

c sharp crystal report

Posted on 2008-11-12
2
Medium Priority
?
1,512 Views
Last Modified: 2012-06-21
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()
        {
            InitializeComponent();
        }
 
        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 == "")) 
            {
                MessageBox.Show("#82I-
7H-@!7- !!!", "%2##'*-", MessageBoxButtons.OK, MessageBoxIcon.Information);
                
                txtCity1.Focus();
                return;
            }
            
            pf.ParameterFieldName = "CurrentCity";
            pdv1.Value = txtCity1.Text;
            pdv2.Value = txtCity2.Text;
            
            pf.CurrentValues.Add(pdv1);
            pf.CurrentValues.Add(pdv2);
            pfs.Add(pf);
            
            crvDisplay.ParameterFieldInfo = pfs;
            crvDisplay.ReportSource = new CustomersByCity();
            crvDisplay.Refresh();   
        }
    }
}

Open in new window

curentCity.JPG
0
Comment
Question by:teera
2 Comments
 
LVL 40

Assisted Solution

by:Richard Quadling
Richard Quadling earned 800 total points
ID: 22940088
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.


0
 
LVL 101

Accepted Solution

by:
mlmcc earned 1200 total points
ID: 22945225
Don't refresh the report at the end.
That clears all parameter values.

mlmcc
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question