我想打印dgv上的内容,.因为dgv上的内容通过查询,得到了一定的数据,不需要打印全部.我不想直接打印dgv,我想通过MicrosoftReportview微软报表在报表中动态的显示,而且要代码绑定报表的 ,dgv在一个窗体,报表在另一个窗体,当我单击dgv中的报表按钮就可以实现我说的功能,希望大侠们谁有示例代码,给我参考参考,小弟感激不尽,小第刚刚接触c#,希望大侠们帮帮忙!!先谢谢了!!

解决方案 »

  1.   

    是不是要直接打印不要预览的
    看看这个http://www.blue1000.com/bkhtml/2010-08/68611.htm
    有问题留言,就不敲代码了。
      

  2.   


            private void Form2_Load(object sender, EventArgs e)
            {
                String strConnection = "Data Source=.;Initial Catalog=职工信息;Integrated Security=True";
                SqlConnection con = new SqlConnection(strConnection);
                String strSQL = "SELECT  * FROM TABLE1";
                SqlDataAdapter da = new SqlDataAdapter(strSQL, con);
              
                //con.Open(); 
                DataSet ds = new DataSet();
                da.Fill(ds);
                BindingSource bindingSource = new BindingSource();
                bindingSource.DataSource = ds;
                //reportViewer1.LocalReport.ReportPath = MapPath(Report1.rdlc);
                Microsoft.Reporting.WinForms.ReportDataSource rds = new Microsoft.Reporting.WinForms.ReportDataSource("职工信息DataSet_TABLE1", ds.Tables["TABLE1"]);
                rds.Value = bindingSource;           // this.reportViewer1.LocalReport.DataSources.Clear();
                this.reportViewer1.LocalReport.DataSources.Add(rds);
                this.reportViewer1.LocalReport.ReportEmbeddedResource = "WindowsFormsApplication1.Report1.rdlc";
                this.reportViewer1.RefreshReport();
                //con.Close()
    这是我调试的一段代码 ,但是在报表的窗体中,却有本地报表处理期间出错,尚未为数据源"职工信息DataSet_TABLE1",提供数据,没有显示数据,你能帮我看看是什么错误吗?那里代码写的有问题,或者需要加入什么代码吗?