天天看点

利用组件形式开发水晶报表

利用枚举类型定义reportID:    

     public enum ChooseReport

        {

            RS485=1,

            MeterInfo=2,

        }

        public static int reportID

页面加载的时候显示相应的报表:

        public void ReportLoad(int i)

        {

            switch (i)

            {

                case 1:

                    CR1 r1 = new CR1();

                    crystalReportViewer1.ReportSource = r1;

                    break;

                case 2:

                    CR2 r2 = new CR2();

                    crystalReportViewer1.ReportSource = r2;

                    break;

            }

        }

        private void ReportViewForm_Load(object sender, EventArgs e)

        {

            PClass p = new PClass();

            toolStripStatusLabel1.Text = PClass.reportID.ToString();

            ReportLoad(PClass.reportID);

        }

继续阅读