Click to See Complete Forum and Search --> : Print MSFlexGrid content


DeLin Shen
September 10th, 2001, 03:28 PM
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.

Iouri
September 10th, 2001, 03:34 PM
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
iouri@hotsheet.com

Iouri
September 10th, 2001, 03:35 PM
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
iouri@hotsheet.com

DeLin Shen
September 12th, 2001, 08:52 AM
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.

Iouri
September 12th, 2001, 09:45 AM
Can you just PrintForm?

Iouri Boutchkine
iouri@hotsheet.com

DeLin Shen
September 12th, 2001, 12:58 PM
PrintForm will just print a black square for the areas where data are in the MSFlexGrid. Thanks