实现下图的效果:
private void Form1_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("ID"); dt.Columns.Add("Name"); dt.Columns.Add("ObjIndex"); DataRow row; for (int i = 1; i <= 10; i++) { row = dt.NewRow(); row["ID"] = Guid.NewGuid(); row["Name"] = "小黄" + i; row["ObjIndex"] = i; dt.Rows.Add(row); } ReportDataSource reportDataSource = new ReportDataSource(); reportDataSource.Name = "DataSet1"; reportDataSource.Value = dt; reportViewer1.Reset(); reportViewer1.LocalReport.ReportPath = "../../Report2.rdlc"; reportViewer1.LocalReport.DataSources.Add(reportDataSource); reportViewer1.RefreshReport(); }
注意RDLC的设置:
第一个框框设置,第二个运算符改为 '=' 号就行了 ,注意对比要改成 integer
利用奇数偶数的原理来显示数据组
本文章做个笔录方便自己以后用到忘了可以查看....