printout quality of MSFlexgrid & text box

Inherited a VB5 project, now running on Windows NT4, that used TextBoxes and FlexGrids to generate reports.

The print quality of fields using text box and flexgrid is horrible -- appears like a dot matrix generated field instead of the usual crisp image that a HP LaserJet usually produces.

Originally the project was designed for Win NT3.x that required use of  text box for word wraping. When we upgraded to Win NT4, I changed text box to lables and solved this print quality problem.

FlexGrid is used to sort the data by several criteria (greatest strengths, greatest needs, etc); the FlexGrid does a nice job, but the printed reports look "cheap". Is there an alternative to FlexGrid that produces good print quality reports, or am I missing a setting or some other code?

Thanks in Advance, brian
Who is Participating?
mark2150Connect With a Mentor Commented:
Problem is that you're basicially dumping a screen snapshot to the printer instead of rendering the output on the print device. Is subtle but important difference.

The images on the screen are a nominal 72 DPI while the laser is 300/600. If you PrintForm to dump what is on screen to printer you'll either get a very tiny (1/4 or 1/8 size), crisp print or you'll get a larger, blocky image. There's no option to get a crisp, large image.

This is because the fonts are rendered at 72DPI and when printed at 300DPI they either print tiny (1:1) or blocky as the 72 DPI is scaled up to 300DPI. Jacking up the printer resolution in the print dialog doesn't help.

The way out of this requires that you completely TOSS the existing print routine and come at it from a different direction. Instead of rendering to the screen and then using a screen dump, you should render directly to the printer. This will allow the printer to interprit the font commands in the best mode it can and will give you beautiful looking printouts.

You have to treat the printer as a plotter. You set the cursor location with .CurrentX/Y and then print a piece of text with Printer.Print "Some Text". This will give you great results, but is pretty much a pain to code.

You can set the printers .Scale property to Inches instead of twips so that you don't have to be converting dimensions all over the place.

You can also then use the .Line and .Circle methods to draw objects on the page. This allows you to exactly duplicate forms that look great no matter what the printer resolution.

Anyway, this is the way to do it.

You'll find that the grid doesn't have a .Print method and you'll be unable to print it with a single command. Rather you'll have to set up a loop and print you data direct from the recordset.

Say I want three columns, one at the left, one at 3" and a third at 6". This is how I'd have to code:

Const Col1 as Double = 0.0
Const Col2 as Double = 3.0
Const Col3 as Double = 6.0
Const BottomMargin as Double = 10.0
Const TopMargin as Double = 1.0
Spacing = 1/6 '6LPI in inches
Printer.Scale (0, 0)-(8, 10.5)  '8-1/2x11 w/ 1/4" margins
Printer.CurrentY = TopMargin  'Start at top of page
' Put heading print commands here...
' Iterate thru recordset printing as you go...
  If Printer.CurrentY > BottomMargin Then
    Printer.CurrentY = TopMargin
  End If
  OldY = Printer.CurrentY
  Printer.CurrentX = Col1
  Printer.Print "" & RS!Field1  'Print column 1
  Printer.CurrentY = OldY
  Printer.CurrentX = Col2
  Printer.Print "" & RS!Field2  'Print column 2
  Printer.CurrentY = OldY
  Printer.CurrentX = Col3
  Printer.Print "" & RS!Field3  'Print column 3
  Printer.CurrentY = OldY + Spacing

You can also determine the width of the text about to be printed by using the .TextWidth property. This allows you to center or right justify by sticking the text in a var and then adjusting the .CurrentX of the text by subtracting either half the .TextWidth to center of all of the .TextWidth to right align.

This is a bit of a pain to code, but the results are well worth it.

Make sure that the .Font property is set to a font which is installed on the system, and is a supported size.
bubba50Author Commented:
already have on code page:
           grdIndivItemStats.Font = "Arial"
           grdIndivItemStats.Font.Size = 11
(and Arial is a standard font that is installed on this computer; 11 is supported)
Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

How is the FlexGrid being printed?  If you are sending the FlexGrid to the printer as an Image, it WILL be grainy.

To solve this problem you will need to format the print yourself by going to each cell and printing it to the printer...

Éric MoreauSenior .Net ConsultantCommented:
There are 3-party grid products our there that have a Print method that does its job very well. I often use Sheridan DataWidgets.

You can download a trial from
All Courses

From novice to tech pro — start learning today.