如何在 stimulsoft 中设置文本格式

How to Set format for Text in stimulsoft

我使用此代码将数字传递给 stimulsoft 报告:

 stiReport1.Load(Application.StartupPath + "\MyReport.mrt");
 (stiReport1.GetComponentByName("Text35") as StiText).Text = Mynumber.ToString();
 stiReport1.RegData(databaseDataSet.Mytable);
 stiReport1.Show();

我在 MyReport 中设置了 Text35 格式,与此图片相同: https://i.imgsafe.org/0a7bb2d.png

但它不起作用,例如显示 12000 而不是 12,000

Text Format无所谓。该数字在您的代码中转换为字符串:

= Mynumber.ToString();

如果您需要更改格式,您应该在 ToString() 方法中进行。

另一种方法是使用数字报告变量,在 Text35 文本组件中使用它并使用下一个代码设置它的值:

report.Dictionary.Variables["Variable1"].Value = yourNumber;

您可以在 c# 中处理它并传递一个格式化的字符串来报告:

Mynumber.ToString("##,###")