c#中的数据网格视图 [英] data grid view in c#

查看:146
本文介绍了c#中的数据网格视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写代码以在datagridview中打印数据作为报告,这是代码:

i write code to print the data in datagridview as a report ,this is the code:

 private void timer1_Tick(object sender, EventArgs e)
        {
            string time = DateTime.Now.Hour + ":" + DateTime.Now.Minute
                                        + ":" + DateTime.Now.Second;

            if (time == "23:18:10")
            {
PrintDocument document = new PrintDocument();
                document.PrintPage += this.PrintPage;

         
                    document.Print();
            }}
        
            private void PrintPage(object sender, PrintPageEventArgs e) {
            using(Font font = new Font("Lucida Console",30)){
                e.Graphics.DrawString(@@@ how can i call the data from datagridview@@, 
                    font, 
                    Brushes.Blue,
                    e.PageBounds.Left, 
                    e.PageBounds.Top);
            }
        }



问题是如何在该代码中调用datagridview?在该代码中看到此标记@@@


the problem is how can i call the datagridview in that code? see this mark @@@ in that code

推荐答案

以下是一种方法。



通过选择列和行来打印DataGridView [ ^ ]
Below is one way of doing it.

DataGridView Printing by Selecting Columns and Rows[^]


您应该使用DataGrid的源打印报告,而不是从DataGrid中提取数据。请参阅类似的文章:使用C#< Crystal Report with DataSet and DataTable [ ^ ]



您还可以查看:

[ ^ ]





- Amit
Instead of extracting data from DataGrid, you should use the source of DataGrid print the report. See a similar article : Crystal Report with DataSet and DataTable using C#[^]

You can also check:
Build Reports using Crystal Reports and Stored Procedures[^]


--Amit


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆