Printing a Report in VB 2005

Posted on 2009-02-12
Last Modified: 2013-11-27

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.

Question by:jstonend
    LVL 96

    Assisted Solution

    by:Bob Learned
    It sounds like you just need multiple DrawString calls, with multiple Font objects defined.

    Author Comment

    Can I do multiple drawstring calls and still have them all print on the same page?
    LVL 83

    Assisted Solution

    I think drawstring takes x and y coordinates. So you just have to use x and y coordinates properly
    LVL 96

    Accepted Solution

    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.


    PrintDocument Class

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Suggested Solutions

    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    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.…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now