コード例 #1
0
        public Reports()
        {
            InitializeComponent();
            mainDal   d = new mainDal();
            DataTable t = d.getReport();

            myGrid.ItemsSource = t.DefaultView;
        }
        public void setData()
        {
            mainDal m = new mainDal();

            DataTable t = m.getReport();

            _reportViewer.LocalReport.DataSources.Clear();
            // it will clear the data source of
            //report if any.
            _reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", t.DefaultView));
            // it will set the data source of report. First argument is dataset and 2nd in the table.
            _reportViewer.LocalReport.ReportPath = "../../Report1.rdlc";
            // this sets the path of //report.
            _reportViewer.LocalReport.EnableExternalImages = true;
            _reportViewer.Visible = true;
            _reportViewer.RefreshReport();
        }