Advertisement

03.17.2008 at 01:09AM PDT, ID: 23246367
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Delphi 7 :: TDBGrid Print Results

Dear Experts,

I would like to print a DBGrid components results.
It would be nice if there is a free component which you can just hook a DBGrid onto it and does the rest for you for example: Printer Setup etc....

Otherwize just straigth forward print method will also help.

Please assist.
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: Marius0188
Solution Provided By: shasunder
Participating Experts: 4
Solution Grade: A
Views: 114
Translate:
Loading Advertisement...
03.17.2008 at 01:14AM PDT, ID: 21140423

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.17.2008 at 01:14AM PDT, ID: 21140428

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.17.2008 at 01:15AM PDT, ID: 21140429

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.17.2008 at 01:29AM PDT, ID: 21140471

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.17.2008 at 01:31AM PDT, ID: 21140479

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.17.2008 at 02:24AM PDT, ID: 21140681

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.17.2008 at 05:02AM PDT, ID: 21141369

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.17.2008 at 05:29AM PDT, ID: 21141508

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.17.2008 at 06:00AM PDT, ID: 21141702

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.17.2008 at 06:14AM PDT, ID: 21141805

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.18.2008 at 05:32AM PDT, ID: 21150226

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.18.2008 at 10:41PM PDT, ID: 21158762

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.18.2008 at 01:29PM PDT, ID: 21389379

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
03.17.2008 at 01:14AM PDT, ID: 21140423
 
03.17.2008 at 01:14AM PDT, ID: 21140428
 
03.17.2008 at 01:15AM PDT, ID: 21140429
more samples that consists of redirect page here

http://www.synchrondata.com/pheaven/www/area44.htm
 
03.17.2008 at 01:29AM PDT, ID: 21140471
You can quite easily just print a picture of the form - but is that what you want?
  Form1.Print

If that works for you, but you don't want to see all the other junk on the form such as buttons etc, then simply create another Form (Form2), put a DBGrid on it, set its Datasource to the same as Form1's DBGrid, then say Form2.Print;

I think ideally you want to print the entire table, not just the contents of the DBGrid - for example what if there are zillions of records in the table - your DBGrid will only be showing a few. For this sort of thing you usually use something like QReport or Rave Report (I believe QReport comes with Delphi, but Rave Report only comes with certain versions) - and Rave Report is "finnicky" -- Quick Report might have some tutorials on how to do this quite easily...

Attached below is an old tip from "Lou's tip of the day" which might be what you're after:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
This tip is similar to yesterday's and added upon request. There are 
several times when I need to send out a 
quick printout of a TDBGrid without having to worry about writting a 
report for it. There are a couple 
different ways of approaching this, we will be looking at the Delphi 
function AssignPrn(). Using 
AssignPrn() we can write to the printer as if we are writting to a file 
using WriteLn(). In this tip we will 
have to change the printer font to a fixed width font so our printout 
will have straight even columns. We will 
be using the Delphi functions Format(), AssignPrn(), WriteLn(), 
Rewrite(), and CloseFile(). 
 
 
    For this tip we will need a TButton with a TButton.OnClick event 
along with a TStringGrid 
    component. You can easily create these events through the Events tab 
of the Object Inspector. 
    First we will need to make sure we add Printers to our Units uses 
clause. 
    In our TButton.OnClick event we will first set our 
TPrinter.PrinterIndex to default printer by setting 
    this value to -1. 
    Next we will be saving our printers font and resetting it to 
'Courier New', a fixed width font. This will 
    make our columns print in a straight even line using the Format() 
Delphi function. 
    Next we will assign our printer textfile to our printer using 
AssignPrn(). 
    After assigning our file we need to initialize it using Rewrite(). 
    Before we loop through the TDBGrid rows, we will print out our 
header and a row of dashes to 
    seperate the header in our printout from the rest of the rows. We 
printout the DBGrid's table fieldnames 
    as the header. 
    We will use the Delphi function WriteLn() to printout each row to 
our assigned printer file. To format 
    the rows properly we will use the Delphi function Format() and input 
all our columns into a formatted 
    string. 
    Next we will loop through our TDBGrid and printout each row in the 
same fashion as we did with the 
    header row. 
    Finally we will need to close the file handle we created with 
AssignPrn() and rest our printer font to 
    its original value.. 
    Format() returns a string formated according to arguments that you 
send in. Format() can get quite 
    complex. Format looks to add the arguments in the order arranged 
into the next position in order 
    according to the percent sign "%" in your format string. In other 
words, you need as many arguments as 
    you have percent signs in your format string parameter. The number 
after the percent sign indicates the 
    max number of characters that will display. When you add a number, a 
period, and a number then this 
    indicates that you want to force that number of characters as 
percision. In other words if you want two 
    characters and your argument only returns one then the return forces 
in a leading character whether it be 
    a space for a string or a zero "0" for a numeric value. The "s" at 
the end of our width and percision 
    indicates that our argument will be passing in a string value to be 
formated into that position. Take a 
    look at the Delphi help file to see all the other values you can 
pass in through the argument parameter. 
    AssignPrn() assigns a textfile variable to the printer. The only 
parameter is the textfile variable. 
    Rewrite() creates a new file and opens it. The only parameter is the 
assigned textfile variable. 
    WriteLn() writes a line of text to our textfile variable. The first 
parameter is the string to write. The 
    second parameter is the textfile variable to write to. 
    CloseFile() gets rid of the association between our textfile and the 
printer file. The only parameter is 
    our assigned textfile variable. 
 
 
        Example 1 
 
 
        {...} 
 
 
        type 
          TForm1 = class(TForm) 
            Button1: TButton; 
            DBGrid1: TStringGrid; 
            procedure Button1Click(Sender: TObject); 
          private 
            { Private declarations }   
          public 
            { Public declarations } 
          end; 
 
 
        {...} 
 
 
        procedure TForm1.Button1Click(Sender: TObject); 
        var 
          MyTextFile     : TextFile; 
          tmpStr,OldFont : String; 
        begin 
          { set to default printer } 
          Printer.PrinterIndex := -1; 
 
 
          { save the printers old font } 
          OldFont := Printer.Canvas.Font.Name; 
 
 
          { set the printers font name to a fixed 
            width font so the printout will have 
            even looking columns } 
          Printer.Canvas.Font.Name := 'Courier New'; 
 
 
          { assign our textfile to the printer } 
          AssignPrn(MyTextFile); 
 
 
          try 
            { initialize our textfile } 
            Rewrite(MyTextFile); 
 
 
            { format and print out our header according 
              to the fieldnames, I only have 2 fields in 
              my table..you will have to add entries to 
              the Format() if you have more fields } 
            tmpStr := Format('%-20.20s %-20.20s', 
 
 
[dbGrid1.DataSource.DataSet.Fields[0].FieldName, 
 
 
dbGrid1.DataSource.DataSet.Fields[1].FieldName]); 
            Writeln(MyTextFile, tmpStr); 
 
 
            { format and print out a seperator between 
              the header and rows } 
            tmpStr := Format('%-20.20s %-20.20s', 
                             ['--------------------', 
                              '--------------------']); 
            Writeln(MyTextFile, tmpStr); 
 
 
            { start at the first record in the DBGrid's table } 
            dbGrid1.DataSource.DataSet.First; 
 
 
            { loop through the DBGrid's table, if the table is 
              too large then you may want to filter it down } 
            while ( not dbGrid1.DataSource.DataSet.EOF ) do 
            begin 
 
 
              { format each row and print them out } 
              tmpStr := Format('%-20.20s %-20.20s', 
 
 
[dbGrid1.DataSource.DataSet.Fields[0].AsString, 
 
 
dbGrid1.DataSource.DataSet.Fields[1].AsString]); 
              Writeln(MyTextFile, tmpStr); 
 
 
              { go to the next record in the DBGrid's table } 
              dbGrid1.DataSource.DataSet.Next; 
            end; 
 
 
          finally 
            { close our textfile } 
            CloseFile(MyTextFile); 
 
 
            { reset the printers font name } 
            Printer.Canvas.Font.Name := OldFont; 
          end; 
        end; 
 
 
        {...} 
Open in New Window
Assisted Solution
 
03.17.2008 at 01:31AM PDT, ID: 21140479
Here's a freeware component that claims to do what you want - I haven't tested it so I can't vouch for it
"TPrintGrid"
http://www.programmersheaven.com/download/5909/download.aspx
http://www.delphi32.com/vcl/1542/
 
03.17.2008 at 02:24AM PDT, ID: 21140681
Hi,

The components don't install. Some errors. :)

Yes I don't just want to print the form.
Need to print all the rows in a DBGrid.
Don't want to setup a report for each grid.
Therefore would like a simple generic way of doing a quick print of a DBGrid's rows and columns.



 
03.17.2008 at 05:02AM PDT, ID: 21141369
you can export them to excel and print form there, if you want i can give some example code.
 
03.17.2008 at 05:29AM PDT, ID: 21141508
Sorry if TPrintGrid didn't work, how about the code I pasted - should be fairly easy to use for your purposes - you just need to adapt it slightly if you have more than 2 fields.
There are also commercial components out there.
 
03.17.2008 at 06:00AM PDT, ID: 21141702
A search on good 'ol Torry's Delphi Pages has this component "DBGrid v.2.0" (Freeware) -- again I haven't tested it:
"Low overhead DBGrid printer unit with preview. Easy to use"
http://www.torry.net/quicksearchd.php?String=print+DBGrid&Title=Yes
 
03.17.2008 at 06:14AM PDT, ID: 21141805
Hi Marius, hope you don't mind if I ask you something - I'm happy to open a question for you to give you points...
Marius, in the next few weeks/months I hope to move back to South Africa -- I'm South African by the way, originally from Joburg, and I presume you work in South Africa using Delphi I thought you might know a thing or two about getting a job there. I am completely self-taught in Delphi, I have no tertiary qualifications or computer qualifications - but for the past 2-4 years I have created my own software company and have developed a software product.
On the one hand there's a skills shortage and Delphi is quite uncommon compared to MS Visual Basic or C so there must be some demand for it and I would say my level of knowledge and skills are pretty good and once you know 1 language you are a huge step closer to using other languages such as C etc, but on the other hand with no relevant work experience except for my own 1-man company and no qualifications, is getting a decent-paid job just a pipe dream?
When you can, just think about this, if you have any advice I would appreciate it, because I'm sure you have some idea of the industry there and the industry in general.
Thanks :)
 
03.18.2008 at 05:32AM PDT, ID: 21150226
Hi rfwoolf,

I am not sure whether we can exchange email adresses on this site.
But you can sent me mail by getting my email from one of our websites.
You should be able to find it on www.signgenius.com  on the contacts page.

Mail me and I will see what I can do.
 
03.18.2008 at 10:41PM PDT, ID: 21158762
Hi rfwoolf,

Please resend your mail but in the subject type:
"SignGenius :: Discussion on Experts-Exchange".

This will ensure that your message wil not be seen as spam by my employees.
 
04.18.2008 at 01:29PM PDT, ID: 21389379
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
   Split: shasunder {http:#21140423} & rfwoolf {http:#21140471}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

ciuly
EE Cleanup Volunteer
 
 
04.26.2008 at 05:28PM PDT, ID: 21447338
Forced accept.

Computer101
EE Admin
 
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628