zoukankan      html  css  js  c++  java
  • C#打印dataGridView中的数据

    这几天,我研究了以下C#如何打印dataGridView中的数据,在网上、图书馆搜索和查阅了一些内容,现总结一下:

    //执行打印窗体中的数据操作

    private void toolStripButton2_Click(object sender, EventArgs e)
            {

                printDialog1.ShowDialog();  //设置打印文档
                printPreviewDialog1.Document = this.printDocument1;
                printPreviewDialog1.ShowDialog();
            }

    //在窗体中绘制要打印的数据

    private void printDocument1_PrintPage(object sender,System.Drawing.Printing.PrintPageEventArgs e)
            {
                //e.Graphics.DrawString(dataGridView1.Columns.ToString(), new Font("宋体", 10, FontStyle.Regular), Brushes.Black, 260, 400);
             
                int r = 0;
                int c = 20;
                for(int i=0;i<dt.Rows.Count;i++)
                {
                 
                    for(int j=0;j<dt.Columns.Count;j++)
                    {
                     
                        e.Graphics.DrawString(dt.Rows[i][j].ToString(), new Font("宋体", 10, FontStyle.Regular), Brushes.Black, r, c);
                        r = r + 60;
                      
                    }
                    r = 0;
                    c += 20;
                  
                }
            }

  • 相关阅读:
    Jboss未授权访问漏洞复现
    jboss反序列化漏洞复现(CVE-2017-7504)
    JBoss 5.x / 6.x反序列化漏洞(CVE-2017-12149)复现
    CVE-2019-5418复现
    CVE-2018-3760复现
    windows第三方提权——FileZilla提权
    msf学习
    脚本木马学习
    sql head注入
    sql 盲注理解
  • 原文地址:https://www.cnblogs.com/zcy_soft/p/1778532.html
Copyright © 2011-2022 走看看