• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

Printing from a FlexGrid

I want to print the contents of most of a flex grid (all but the top row),in addition to a heading (One line, large text), and column headings. The contents of the flexgrid and the column headings need to be aligned, and preferably I need divider lines between them. I have looked at the printer object but have had no success, particularaly in regards to positioning text. Help!
0
Arachn1d
Asked:
Arachn1d
1 Solution
 
VbmasterCommented:
Positioning text can be done using the .CurrentX and .CurrentY properties, for example if you want to position the text "What to type here" with the beginning at the coordinates (10 , 20) you just code..

Printer.CurrentX = 10
Printer.CurrentY = 20
Printer.Print "What to type here"

The printer object uses the same scale object model that any other control/form VB has, so to get the coordinates in something easier to understand you can set it to millimeters using code like

Printer.ScaleMode = vbMillimeters

If you add this code before the three code lines above you will get the "What to type here" string printed 10 mm from the left side of the paper and 20 mm from the top border of the paper.

Well not exactly 10mm and 20mm, printers do have a internal limitation so it might be 15mm and 25mm because the printer adds it's own margins to those values.
0
 
watyCommented:
' #VBIDEUtils#************************************************************
' * Programmer Name  : Waty Thierry
' * Web Site         : www.geocities.com/ResearchTriangle/6311/
' * E-Mail           : waty.thierry@usa.net
' * Date             : 29/04/99
' * Time             : 13:26
' **********************************************************************
' * Comments         : Print MSFlexGrid
' *
' *
' **********************************************************************

Public Sub MSFlexGridPrint(gridQuery As Control)
   ' *** Print MSFlexGrid

   Dim I          As Integer
   Dim J          As Integer
   Dim PTab       As Integer

   For I = 1 To gridQuery.Rows - 1
      PTab = 20 'Set the first tab value
      'This checks to see if a page break is needed

      If Printer.CurrentY + Printer.TextHeight(gridQuery.Text) > Printer.ScaleHeight - 600 Then
         Printer.NewPage
      End If

      gridQuery.Row = I 'Set the active row

      For J = 0 To gridQuery.Cols - 1
         gridQuery.Col = J 'Set the current column
         
         'Send the field to the print line and add the tab.
         'Notice the semicolon at the end of the line.

         Printer.Print Trim$(gridQuery.Text); Tab(PTab);

         PTab = PTab + 20 'Increment the tab value
      Next

      'After each column has printed to the print line

      'a Printer.Print statement without a semicolon will
      'will send the line to the printer and start a new
      'one.
      Printer.Print
   Next

End Sub  

0
 
Arachn1dAuthor Commented:
Thanks anyway, but I figured it out myself and forgot to delete the question. Here's the points anyway since your answer also seems to answer the question quite satisfactorially.

Thanks.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now