CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2001
    Posts
    12

    Print MSFlexGrid content

    If I have a form with a MSFLEXGrid control on it. There are some data in the MSFlexGrid, how do I make a hard copy of those data in MSFlexGrid? Any help would be appreciated.


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

    Re: Print MSFlexGrid content

    Print MSFlexGrid
    ================
    Here's a quick way to print a MSFlexGrid control's contents:
    Printer.PaintPicture MSFlexGrid_Name.Picture, 0, 0
    Printer.EndDoc

    And if you want it to be the full length of the printer page add this before those two statements:
    Dim old_width as Integer
    MSFlexGrid_Name.width=printer.width

    and this at the end:
    MSFlexGrid_Name.width=old_width



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

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

    Re: Print MSFlexGrid content

    if you have long msfg ( longer than 1 page )


    Sub PrintMSFG(ByVal pHorizontal as Boolean)
    Dim i As Integer
    Dim iMaxRow As Integer
    Dim j As Integer
    Dim msfGrid As MSFlexGrid
    Dim iPage As Integer
    ' frmLoan.MSFlexGrid1 is an invisible msflexgrid
    ' used only for this routine
    ' put it where your want and reference it apropiately

    Set msfGrid = Me.MSFlexGrid1
    msfGrid.FixedCols = 0
    msfGrid.Clear

    If pHorizontal = True Then
    Printer.Orientation = vbPRORLandscape
    iMaxRow = 44
    Else
    Printer.Orientation = vbPRORPortrait
    iMaxRow = 57
    End If

    If msfg.Rows Mod iMaxRow = 0 Then
    iPage = msfg.Rows \ iMaxRow
    Else
    iPage = msfg.Rows \ iMaxRow + 1
    End If
    msfGrid.Rows = iMaxRow
    msfGrid.Cols = msfg.Cols


    For i = 0 To msfg.Cols - 1
    msfGrid.ColWidth(i) = msfg.ColWidth(i)
    Next
    Screen.MousePointer = vbHourglass

    If pHorizontal = True Then
    Printer.CurrentX = 10000
    Else
    Printer.CurrentX = 7000
    End If

    For i = 0 To msfg.Rows - 2 + iPage
    If i Mod iMaxRow = 0 And i > 0 Then
    With msfGrid
    .Row = 0
    .Col = 0
    .ColSel = 0
    .RowSel = 0

    If pHorizontal Then
    Printer.PaintPicture .Picture, 20, 1250, 15000, 10350
    Else
    Printer.PaintPicture .Picture, 20, 1250, 11400, 13950
    End If

    End With
    Printer.NewPage
    msfGrid.Clear


    For j = 0 To msfGrid.Cols - 1
    msfGrid.TextMatrix(0, j) = msfg.TextMatrix(0, j)
    Next
    If pHorizontal = True Then
    Printer.CurrentX = 10000
    Else
    Printer.CurrentX = 7000
    End If
    Printer.CurrentY = 0
    i = i + 1
    End If
    For j = 0 To msfGrid.Cols - 1
    msfGrid.TextMatrix(i Mod iMaxRow, j) = msfg.TextMatrix(i - i \ iMaxRow, j)
    Next
    Next


    With msfGrid
    .Row = 0
    .Col = 0
    .ColSel = 0
    .RowSel = 0
    If pHorizontal Then
    Printer.PaintPicture .Picture, 20, 1250, 15000, 10350
    Else
    Printer.PaintPicture .Picture, 20, 1250, 11400, 13950
    End If
    End With
    Printer.EndDoc
    Set msfGrid = Nothing
    Screen.MousePointer = vbDefault
    End Sub





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

  4. #4
    Join Date
    May 2001
    Posts
    12

    Re: Print MSFlexGrid content

    Thank you very much for the suggestion. I have another question. How would I print out the content the MSFlexGrid togather with other content of the form where MSFlexGrid is located? Thank you.


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

    Re: Print MSFlexGrid content

    Can you just PrintForm?

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

  6. #6
    Join Date
    May 2001
    Posts
    12

    Re: Print MSFlexGrid content

    PrintForm will just print a black square for the areas where data are in the MSFlexGrid. Thanks


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