我是Stimulsoft Reports的新手,我在这里苦苦挣扎。我无法在报告中显示数据集。我创建了一个简单的Report.mrt文件,但它是空的。这是我到目前为止所做的...
private void button1_Click(object sender, EventArgs e)
{
DataTable table = GetTable();
DataSet ds = new DataSet("office");
ds.Tables.Add(table);
ds.Namespace = "y";
ds.Prefix = "x";
stiReport1.RegData("MyDataSet", ds);
stiReport1.Load("D:\\Report.mrt");
stiReport1.Show();
}
public DataTable GetTable()
{
DataTable table = new DataTable();
table.Columns.Add("Dosage", typeof(int));
table.Columns.Add("Drug", typeof(string));
table.Columns.Add("Patient", typeof(string));
table.Columns.Add("Date", typeof(DateTime));
table.Rows.Add(25, "Indocin", "David", DateTime.Now);
table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
table.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);
return table;
}
这没有显示任何内容,我不知道该怎么做。我应该向Report.mrt添加一些文本字段吗?
答案 0 :(得分:1)
首先,我会在stiReport1.Load
之前移动stiReport1.RegData
然后你应该编译报告
stiReport1.Load("D:\\Report.mrt");
stiReport1.RegData("MyDataSet", ds);
stiReport1.Dictionary.Synchronize();
stiReport1.Compile();
stiReport1.Show(true);