CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2000
    Posts
    32

    Printing a DataGrid

    Ok Last question,

    What is the best method for printing the content of a datagrid control???

    Thanks Chad


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Printing a DataGrid

    Private Sub Command1_Click()
    Call GridPrint(DataGrid1)
    End Sub

    Public Sub GridPrint(gridQuery As DataGrid)
    Dim I As Integer
    Dim J As Integer
    Dim PTab As Integer

    For I = 0 To gridQuery.ApproxCount - 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

    On Error Resume Next
    gridQuery.Row = I 'Set the active row
    On Error GoTo 0

    For J = 0 To gridQuery.Columns.Count - 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
    Printer.EndDoc
    End Sub

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured