2013-07-18 84 views
0

我是Stimulsoft Reports的新手,我在這裏苦苦掙扎。我無法顯示報告中的數據集。我創建了一個簡單的Report.mrt文件,但它是empty.this是我迄今所做的......在winform中顯示stimulsoft報告

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添加一些文本字段嗎?

回答

1

首先,我會在stiReport1.RegData之前移動stiReport1.Load
然後你應該編譯報告

stiReport1.Load("D:\\Report.mrt"); 
stiReport1.RegData("MyDataSet", ds); 
stiReport1.Dictionary.Synchronize(); 
stiReport1.Compile(); 
stiReport1.Show(true);