FastReport.net中的减2值

时间:2012-02-29 20:57:08

标签: fastreport

我希望Minus能够在页脚中使用FastReport.Net。 我的代码:

private void PageFooter1_BeforeLayout(object sender, EventArgs e)
    {
      Text22.Text=Convert.ToString(Convert.ToDouble(Text12.Text)-Convert.ToDouble(Text3.Text));
    }

并且发生了此错误:

FastReport.Net v1.7.33
Exception has been thrown by the target of an invocation.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.FormatException: Input string was not in a correct format.
   at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
   at FastReport.ReportScript.PageFooter1_BeforeLayout(Object sender, EventArgs e)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at FastReport.Code.ExpressionDescriptor.Invoke(Object[] parameters)
   at FastReport.BandBase.CalcHeight()
   at FastReport.Engine.ReportEngine.ShowBandToPreparedPages(BandBase band, Boolean getData)
   at FastReport.Engine.ReportEngine.ShowBand(BandBase band, Boolean getData)
   at FastReport.Engine.ReportEngine.EndLastPage()
   at FastReport.Engine.ReportEngine.RunReportPage(ReportPage page)
   at FastReport.Engine.ReportEngine.RunReportPages()
   at FastReport.Engine.ReportEngine.RunReportPages(ReportPage page)
   at FastReport.Engine.ReportEngine.Run(Boolean runDialogs, Boolean append, ReportPage page)
   at FastReport.Report.Prepare(Boolean append)
   at FastReport.Design.ReportTab.Preview()

任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

您可以尝试DataTextFormatString="{0:Axx}",并将代码放入BeforePrint事件中。

例如:

private void Text14_BeforePrint(object sender, EventArgs e)
{
    Text14.Text=string.Format("{0:N}",((Decimal)Report.GetColumnValue("Table.money"))-((Decimal)Report.GetColumnValue("Table.TRSMONEY")));
}