Esempio n. 1
0
        private void btnPrint_Click(object sender, System.EventArgs e)
        {
            try
            {
                this.tabChart.BackColor = Color.White;
                crc16.CaptureScreen cs = new crc16.CaptureScreen();
                this.m_cs = cs;
                cs.CaptureScreen(this, this.tabPage1);
                this.printDocument1.DefaultPageSettings.Landscape = true;
                int iWidth  = (int)(21 / 2.54 * 100);
                int iHeight = (int)(29.75 / 2.54 * 100);

                this.printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("A4", iWidth, iHeight);
                this.printPreviewDialog1.Document    = this.printDocument1;
                this.printPreviewDialog1.WindowState = FormWindowState.Maximized;
                this.printPreviewDialog1.ShowDialog();
            }
            catch (Exception ex)
            {
                if (ex.ToString().IndexOf("取消") >= 0)
                {
                    MessageBox.Show("打印已取消!");
                    return;
                }
                MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 2
0
        private void btnPrint_Click(object sender, System.EventArgs e)
        {
            try
            {
                this.tabChart.BackColor=Color.White;
                crc16.CaptureScreen cs=new crc16.CaptureScreen();
                this.m_cs =cs;
                cs.CaptureScreen(this,this.tabPage1);
                this.printDocument1.DefaultPageSettings.Landscape = true;
                int iWidth  = (int)(21 / 2.54 * 100);
                int iHeight = (int)(29.75 / 2.54 * 100);

                this.printDocument1.DefaultPageSettings.PaperSize=new System.Drawing.Printing.PaperSize("A4", iWidth, iHeight);
                this.printPreviewDialog1.Document=this.printDocument1 ;
                this.printPreviewDialog1.WindowState = FormWindowState.Maximized;
                this.printPreviewDialog1.ShowDialog();

            }
            catch(Exception ex)
            {
                if(ex.ToString().IndexOf("ȡ��")>=0)
                {
                    MessageBox.Show("��ӡ��ȡ����");
                    return;
                }
                MessageBox.Show(ex.ToString());
            }
        }