在Winform和C#中,如何在FastReport中水平显示数据集中的数据?
示例:
1 2 3 4 5 ...
最后,我希望以特定的列数显示Matrix格式的数据。
示例:
+-----+-----+-----+-----+-----+
| 1 | 2 | 3 | 4 | 5 |
+-----+-----+-----+-----+-----+
| 6 | 7 | 8 | 9 | 10 |
+-----+-----+-----+-----+-----+
我的努力:
手动添加FastReport.TextObject
控件。
在这种情况下,当我通过页面时,我无法找到。
使用Table
控件。但我在数据库中只有一列,我无法解决这个问题。
答案 0 :(得分:1)
参见FastReport Demo【表>列数据源】
演示下载链接:https://【快速报告网址】/ en / download / fast-report-net /
private void Table1_ManualBuild(object sender, EventArgs e)
{
// get the data source by its name
DataSourceBase columnData = Report.GetDataSource("Employees");
// init the data source
columnData.Init();
// print the first table column - it is a header
Table1.PrintColumn(0);
// each PrintColumn call must be followed by either PrintRow or PrintRows call
// to print cells on the column
Table1.PrintRows();
// now enumerate the data source and print the table body
while (columnData.HasMoreRows)
{
// print the table body
Table1.PrintColumn(1);
Table1.PrintRows();
// go next data source row
columnData.Next();
}
// print the last table column - it is a footer
Table1.PrintColumn(2);
Table1.PrintRows();
}
答案 1 :(得分:1)
使用Table ManualBuild Event,您可以水平显示数据,如下所示:
(我无法上传.frx,因此您可以下载快速报告演示并查看详细信息)
private void Table1_ManualBuild(object sender, EventArgs e)
{
// get the data source by its name
DataSourceBase columnData = Report.GetDataSource("Employees");
// init the data source
columnData.Init();
// print the first table column - it is a header
Table1.PrintColumn(0);
// each PrintColumn call must be followed by either PrintRow or PrintRows call
// to print cells on the column
Table1.PrintRows();
// now enumerate the data source and print the table body
while (columnData.HasMoreRows)
{
// print the table body
Table1.PrintColumn(1);
Table1.PrintRows();
// go next data source row
columnData.Next();
}
// print the last table column - it is a footer
Table1.PrintColumn(2);
Table1.PrintRows();
}