Printing a .NET DataGridView

后端 未结 9 774
南旧
南旧 2020-12-08 05:33

I am fairly new to .NET and C#, but I have a DataGridView that I would like to print. What would be the best way to go about doing so?

相关标签:
9条回答
  • 2020-12-08 05:55

    On CodeProject:

    Another DataGridView Printer by aureolin

    Above is another excellent DataGridView Printer that is extremely simple to implement.

    I realize I am a Johnny Come Lately to this thread. I stumbled upon it while searching for something else, but wanted to reference this excellent printing solution for others who happen by this way (as I did).

    I hope someone here gets some use out of it.

    0 讨论(0)
  • 2020-12-08 05:59

    I know you've already accepted an answer, but for the next person to search this question...

    I also found this wonderful project on Code Project, and just implemented it. It was EASY and nice. http://www.codeproject.com/KB/grid/GridDrawer.Net.aspx

    0 讨论(0)
  • 2020-12-08 06:02

    I like this method http://www.codeproject.com/KB/grid/GridDrawer.Net.aspx But is there any way I can choose the printer.

    I want to auto print at the end of a process. So planing to choose this as options 1, so i can always print to default printer. And another option like to choose the printer and then print. So in total 2 ptint function in all. Please reply. Cheers

    0 讨论(0)
  • 2020-12-08 06:07

    .NET WinForm controls (like the datagridview) do not natively support being printed.

    In the case of the datagridview, though, you can call 'DrawToBitmap', and then take that bitmap and pass it on to the printing functions in order to produce it on paper.

    0 讨论(0)
  • There are projects on CodeProject that have done some work printing DataGridViews.

    0 讨论(0)
  • 2020-12-08 06:12

    You could export the DataGridView to Excel and then print it from Excel.

    You could also consider to not show your data in a DataGridView, but show it in a ReportViewer control, which has the ability to export to PDF or Excel. From there it's possible to print your data.

    0 讨论(0)
提交回复
热议问题