简体   繁体   中英

Winform to Crystal Report value changes

Why does a value from a certain Winform change when passing to a report?

for example from a form I have a string 1311-0015 but when I pass it to a Formula Field it becomes 1,296.00

http://i.imgur.com/oeIwrAU.jpg

Passing it to a TextObject doesn't change the value it's still 1311-0015 but I can't use TextObjects in formulas in Crystal Report.

Would like to know why this is happening and how to remedy the problem.

this is the code from the winForm:

report.DataDefinition.FormulaFields["SOS"].Text = transactionId; ((TextObject)report.Section2.ReportObjects["Text3"]).Text = transactionId;

the value I was passing to the crystal report:

public string transactionId = "1311-0015";

You said you are passing the value to a formula field. If there is nothing in the formula, and you pass 1311 - 15 to the formula, it will evaluate it. Instead of a formula field, use a text box or modify the string so it doesn't come out like an equation. For your transactionID value try something like:

""1311" & "-" & "0015""

You may need to have two separate public string transactionId variables.

You can pass this string as parameter. First, create a parameter field in you Crystal Reports editor. (Right button, New...)

参数栏位

Code something like this:

string transactionID = "1311-0015";

yourRpt.SetDatasource(youDataSource);
yourRpt.Parameters.SetParameterValue("transactionID", transactionID);

Now, you just need to drag and drop the parameter field into the report.

You should create a parameter and use its value inside the formula. In order to avoid showing parameters dialog box make sure that the parameter value is set (you should do this in your code) and set: yourReport.EnableParameterPrompting = false;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM