如何打印数据网格视图C#GUI中的所有行

如何打印数据网格视图C#GUI中的所有行

本文介绍了如何打印数据网格视图C#GUI中的所有行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们



我有一个数据Gridview和一个按钮,试图在按钮点击时打印网格。因为我有正确的下面的代码,但这不打印所有的行只是pring那行在网格视图中是visibal更多行是谁可以查看向下滚动向上,所以我希望所有行和列打印



_____________________________________________________________________________________

位图bm =新位图(this.dataGridView1.Width,this.dataGridView1.Height); 
dataGridView1.DrawToBitmap(bm,new Rectangle(0,0,this.dataGridView1.Width,this.dataGridView1.Height));
e.Graphics.DrawImage(bm,150,400);



e.Graphics.DrawRectangle(Pens.Black,100,100,
dataGridView1.Columns [0] .Width,dataGridView1.Rows [0]。高度);


e.Graphics.FillRectangle(Brushes.LightGray,new Rectangle
(100,100,dataGridView1.Columns [0] .Width,dataGridView1.Rows [0] .Height ));



e.Graphics.DrawString(dataGridView1.Columns [0] .HeaderText,
dataGridView1.Font,Brushes.Black,new RectangleF(100,100,
dataGridView1.Columns [0] .Width,dataGridView1.Rows [0] .Height));



_____________________________________________________________________________________

解决方案

Dear Firends

I have a data Gridview and one button and trying to print grid on button click. for i have right following code,but this is not printing all the row it is only pring that row who are visibal in grid view some more row are there who can view after scroll down and up so i want all row and column to be print

_____________________________________________________________________________________

Bitmap bm = new Bitmap(this.dataGridView1.Width, this.dataGridView1.Height);
            dataGridView1.DrawToBitmap(bm, new Rectangle(0, 0, this.dataGridView1.Width, this.dataGridView1.Height));
            e.Graphics.DrawImage(bm, 150, 400);



            e.Graphics.DrawRectangle(Pens.Black, 100, 100,
    dataGridView1.Columns[0].Width, dataGridView1.Rows[0].Height);


            e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle
                (100, 100, dataGridView1.Columns[0].Width, dataGridView1.Rows[0].Height));



            e.Graphics.DrawString(dataGridView1.Columns[0].HeaderText,
                dataGridView1.Font, Brushes.Black, new RectangleF(100, 100,
                dataGridView1.Columns[0].Width, dataGridView1.Rows[0].Height)); 


_____________________________________________________________________________________

解决方案


这篇关于如何打印数据网格视图C#GUI中的所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 20:53