?
Solved

Printing a Report in VB 2005

Posted on 2009-02-12
4
Medium Priority
?
295 Views
Last Modified: 2013-11-27
Hello,

I'm trying to print a report using Visual Basic 2005.  I am currently using the Print Dialog to setup the page to print and the "DrawString" method from the graphics class to actually print the document.

The problem is that I have to send a complete string into the "DrawString" object with all the font settings done in advance - 1 set of settings per string - I need to be able to change the font, font size and font style in different places in the string.

Could someone point me in the right direction.

Thanks.
0
Comment
Question by:jstonend
  • 2
4 Comments
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 1600 total points
ID: 23640428
It sounds like you just need multiple DrawString calls, with multiple Font objects defined.
0
 

Author Comment

by:jstonend
ID: 23642500
Can I do multiple drawstring calls and still have them all print on the same page?
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 400 total points
ID: 23643105
I think drawstring takes x and y coordinates. So you just have to use x and y coordinates properly
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1600 total points
ID: 23644776
Yes, there are overloaded methods for DrawString (some that take Point, and some that take Rectangle arguments), and you can make as many as you need.  The PrintDocument fires the Print event for each page, and you must set e.HasMorePages = True to keep printing pages.  All the draw methods, like DrawString, DrawRectangle, FillRectangle, etc., can be used in loops, with multiple single calls, whatever you need.

Example:

PrintDocument Class
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question