What's the best method to print from my C# program?
I have written开发者_Python百科 a winform program that gathers information from several database tables and displays this information in a datagridview. The user likes it a lot, but they've requested an additional feature: the ability to print the information in the datagridview to their printer.
All of the data that the user wants to print is in the datagridview. If you had to make this kind of change to this program, what method would you use to get the information to the printer?
codeproject's got a bunch:
The DataGridViewPrinter Class
Printing of DataGridView
Another DataGridView Printer
Printing a DataGridView on DotNet Framework
DataGridView Print/Print Preview Solution - Part I
DataGridView Print/Print Preview Solution - Part II
Plus more. I haven't tried any of these myself though.
One way of doing that nicely, if you are able to, is create/design a local report (.rdlc) and print that report without showing the ReportViewer control. An example of that is here.
精彩评论