2012-02-29 40 views
0

我希望在頁腳的FastReport.Net中減值。 我的代碼:FastReport.net中減2值

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

您可以嘗試做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"))); 
}