Ejemplo n.º 1
0
        //打印
        void UC_PrintEvent(object sender, EventArgs e)
        {
            DataTable dt = this.dgvRecord.GetBoundData();

            if (dt.Rows.Count == 0)
            {
                return;
            }

            int        width  = this.reportPrint.PaperSize.Width - this.reportPrint.PaperMergin.Left - this.reportPrint.PaperMergin.Right;
            int        height = this.reportPrint.PaperSize.Height - this.reportPrint.PaperMergin.Top - this.reportPrint.PaperMergin.Bottom;
            PrintTable table  = new PrintTable();

            //设定列宽度
            foreach (DataGridViewColumn dgvc in this.dgvRecord.Columns)
            {
                if (dt.Columns.Contains(dgvc.Name))
                {
                    PrintColumn pc = new PrintColumn();
                    pc.Name = dgvc.Name;
                    pc.Text = dgvc.HeaderText;
                    if (this.dgvRecord.MergeColumnNames.Contains(dgvc.Name))
                    {
                        pc.IsMerged = true;
                    }
                    else
                    {
                        pc.IsMerged = false;
                    }

                    pc.Width = dgvc.Width;
                    table.AddColumn(pc);
                }
            }
            table.DataSourse = dt;

            //头标题
            table.drawHead   += new PrintTable.DrawHeadHandler(this.DrawHead);
            table.HasTitle    = true;
            table.TitleHeight = 40;

            this.reportPrint.PrintMethod = PrintMethods.PrintReport;

            //ServiceStationClient.ComponentUI.FormPrint formPrint = new ServiceStationClient.ComponentUI.FormPrint(table, this.reportPrint);
            //formPrint.TitleFont = new Font("宋体", 11);

            //formPrint.Show();
        }
Ejemplo n.º 2
0
        //打印
        void UC_PrintEvent(object sender, EventArgs e)
        {
            DataTable dt = this.dgvRecord.GetBoundData();
            if (dt.Rows.Count == 0)
            {
                return;
            }

            int width = this.reportPrint.PaperSize.Width - this.reportPrint.PaperMergin.Left - this.reportPrint.PaperMergin.Right;
            int height = this.reportPrint.PaperSize.Height - this.reportPrint.PaperMergin.Top - this.reportPrint.PaperMergin.Bottom;
            PrintTable table = new PrintTable();
            //设定列宽度
            foreach (DataGridViewColumn dgvc in this.dgvRecord.Columns)
            {               
                if (dt.Columns.Contains(dgvc.Name))
                {
                    PrintColumn pc = new PrintColumn();
                    pc.Name = dgvc.Name;
                    pc.Text = dgvc.HeaderText;
                    if (this.dgvRecord.MergeColumnNames.Contains(dgvc.Name))
                    {
                        pc.IsMerged = true;
                    }
                    else
                    {
                        pc.IsMerged = false;
                    }
                    
                    pc.Width = dgvc.Width;
                    table.AddColumn(pc);
                }
            }
            table.DataSourse = dt;

            //头标题
            table.drawHead += new PrintTable.DrawHeadHandler(this.DrawHead);
            table.HasTitle = true;
            table.TitleHeight = 40;          

            this.reportPrint.PrintMethod = PrintMethods.PrintReport;

            //ServiceStationClient.ComponentUI.FormPrint formPrint = new ServiceStationClient.ComponentUI.FormPrint(table, this.reportPrint);
            //formPrint.TitleFont = new Font("宋体", 11);
           
            //formPrint.Show();       
        }