Posted by meysam on August 17, 2003 at 05:27:43:
In Reply to: Re: Printing posted by webmaster Guido on February 21, 19103 at 14:07:49:
: : is thier any way to print just the dbgrid on a form with all the fields and values just at the press of a button??thier are other things on the form but i dont wont these printing, just the table with ALL the information stored in it.
: There is no simple command to print the contents of a DBGrid or a complete table. So you either write the entire code for this yourself, or you use a report generator to print out data from your table (such as QuickReport which is included with Delphi), or install a component that can print a DBGrid. There are some freeware as well as shareware components for this; some suggested keywords for the search engines: delphi dbgrid print component.
: ...and this example only prints some constant demo lines, so you still have to add the part that extracts data from the table and feeds the data to the printing code.
: With Form1.Print you can print a graphical image of the entire form. That limits the number of records that are printed to the data that are visible in the DBGrid, and of course all the other components of the form are printed too. So here's an idea for a work around: put a copy of the DBGrid on its own form (say Form2), entirely filling Form2. When the print-button is clicked, show Form2, synchronize the grid on Form2 with the original grid, do a Form2.Print and finally hide Form2 again ;-)
[ DelphiLand: free Delphi source code, tips, tutorials ]