Crystal Report fields
-
Sorry to post a Crystal Report question in here, but I don't know where else to ask it, since I'm using it in C#. I have no problem passing datasets to my report...everything works fine. BUT...I can't seem to find a way of passing a simple variable into my report. I just want to print 2 separate dates on my report, that definitely doesn't require an entire dataset just for 2 dates...but I don't know how to put them in my report. The closest I've come is using a parameter field...but then I have to input the dates in that dialog box that pops up, and I don't like that. I just want to do it programmatically so the user never knows how it happened. Any ideas? Thanks
-
Sorry to post a Crystal Report question in here, but I don't know where else to ask it, since I'm using it in C#. I have no problem passing datasets to my report...everything works fine. BUT...I can't seem to find a way of passing a simple variable into my report. I just want to print 2 separate dates on my report, that definitely doesn't require an entire dataset just for 2 dates...but I don't know how to put them in my report. The closest I've come is using a parameter field...but then I have to input the dates in that dialog box that pops up, and I don't like that. I just want to do it programmatically so the user never knows how it happened. Any ideas? Thanks
parameter fields is exactly what you need. Here is some howto (cut from visual studio help): Parameter Fields Runtime Customization You can support user input with parameters in Crystal reports. Such parameters can be used for a variety of purposes. For example: Base a parameter on a database field and allow the user to specify values for that field to filter data in the report. Apply conditional formatting to a report by using parameter fields. Define sort order by using parameter fields. The following example demonstrates how parameter field values can be set, through code, at runtime. It explains how to set two different parameters. The first is a multiple-value discrete parameter, and the second is a range value parameter. To Modify Parameter Fields at Runtime [C#]
// Declare variables needed to pass the parameters // to the viewer control. ParameterFields paramFields = new ParameterFields (); ParameterField paramField = new ParameterField (); ParameterDiscreteValue discreteVal = new ParameterDiscreteValue (); ParameterRangeValue rangeVal = new ParameterRangeValue (); // The first parameter is a discrete parameter with multiple values. // Set the name of the parameter field, this must match a // parameter in the report. paramField.ParameterFieldName = "Customer Name"; // Set the first discrete value and pass it to the parameter. discreteVal.Value = "AIC Childrens"; paramField.CurrentValues.Add (discreteVal); // Set the second discrete value and pass it to the parameter. // The discreteVal variable is set to new so the previous settings // will not be overwritten. discreteVal = new ParameterDiscreteValue (); discreteVal.Value = "Aruba Sport"; paramField.CurrentValues.Add (discreteVal); // Add the parameter to the parameter fields collection. paramFields.Add (paramField); // The second parameter is a range value. The paramField variable // is set to new so the previous settings will not be overwritten. paramField = new ParameterField (); // Set the name of the parameter field, this must match a // parameter in the report. paramField.ParameterFieldName = "Customer ID"; // Set the start and end values of the range and pass it to the // parameter. rangeVal.StartValue = 42; rangeVal.EndValue = 72; paramField.CurrentValues.Add (rangeVal); // Add the second parameter to the parameter fields collection. paramFields.Add (paramField); // Set the parameter fields collection into the viewer control. crystalReportViewer1.ParameterFiel
-
Sorry to post a Crystal Report question in here, but I don't know where else to ask it, since I'm using it in C#. I have no problem passing datasets to my report...everything works fine. BUT...I can't seem to find a way of passing a simple variable into my report. I just want to print 2 separate dates on my report, that definitely doesn't require an entire dataset just for 2 dates...but I don't know how to put them in my report. The closest I've come is using a parameter field...but then I have to input the dates in that dialog box that pops up, and I don't like that. I just want to do it programmatically so the user never knows how it happened. Any ideas? Thanks
threre is 2 simple way : 1- using textobject for sending value to your report: create textobject with TextTimeFrom name(or desired name) then in your code set value for TextTimeFrom textobject ...C# code ((TextObject)ReportOne.ReportDefinition.ReportObjects["TextTimeFrom"]).Text = "12:25"; .... this value is placed on your report because textobject will be placed on report area if you want to send parameter to conitional approach use formula field and you can place formula field object on your form or not! second way byy using formula fields 2- create one formula field with YearValue(or desired name,YearValue just is sample name) name and then set that value in your code like this : ...C# code ReportOne.DataDefinition.FormulaFields["YearValue"].Text= "value; (ReportOne is your report ReportDocument object) .... you see it is very simple just with one line coding enjoy of it