Example #1
0
        private void buttonRunReport_Click(object sender, EventArgs e)
        {
            XmlReader xmlReader = null;

            // Select the report in the Viewer.
            //
            if (radioButtonProductListReport.Checked)
            {
                xmlReader = XmlReader.Create(Properties.Resources.ProductsReport);
            }
            else if (radioButtonCategoriesReport.Checked)
            {
                xmlReader = XmlReader.Create(Properties.Resources.CategoryReport);
            }

            var report = new SectionReport();

            report.LoadLayout(xmlReader);
            // Apply stylesheet on the report.
            //
            string outputFolder = new FileInfo(GetType().Assembly.Location).DirectoryName + "\\";

            string styleSheet = "";

            if (radioButtonClassicStyle.Checked)
            {
                styleSheet = outputFolder + "Classic.reportstyle";
            }
            else if (radioButtonColoredStyle.Checked)
            {
                styleSheet = outputFolder + "Colored.reportstyle";
            }
            else if (_externalStyleSheet != "")
            {
                styleSheet = _externalStyleSheet;
            }

            if (styleSheet != "")
            {
                report.LoadStyles(styleSheet);
            }
            reportViewer.LoadDocument(report);
        }