| | |
how to print msflexgird and the data in this flexgrid
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Aug 2008
Posts: 28
Reputation:
Solved Threads: 0
Let's try this code.. I've been using it and it works excellent!!
And also this..
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Sub cmdPrint_Click() 'Print the grid with the top row as a title row FlexGridPrint Me.Grd, , , , , 1 End Sub
And also this..
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Function FlexGridPrint(Grd As MSFlexGrid, Optional lOrientation As Long = vbPRORPortrait, Optional ByVal lMaxRowsPerPage As Long = -1, Optional lTopBorder As Long = 1000, Optional lLeftBorder As Long = 1000, Optional lRowsToRepeat As Long = 0) As Boolean Dim lRowsPrinted As Long, lRowsPerPage As Long Dim lThisRow As Long, lNumRows As Long, lImageHeight As Long, lLastImageTop As Long Dim lPrinterPageHeight As Long, lPagesPrinted As Long, lHeadingHeight As Long On Error GoTo ErrFailed Grd.TopRow = 1 lNumRows = Grd.Rows - 1 lPrinterPageHeight = Printer.Height lRowsPerPage = lMaxRowsPerPage lRowsPrinted = lRowsToRepeat If lRowsToRepeat Then 'Calculate the height of the heading row For lThisRow = 1 To lRowsToRepeat lHeadingHeight = lHeadingHeight + Grd.RowHeight(lThisRow) Next End If Do 'Calculate the number of rows for this page lImageHeight = 0 lRowsPerPage = 0 'Setup printer Printer.Orientation = lOrientation For lThisRow = lRowsPrinted To lNumRows lImageHeight = lImageHeight + Grd.RowHeight(lThisRow) If lRowsPerPage > lMaxRowsPerPage And lMaxRowsPerPage <> -1 Then 'Image has required number of rows, subtract height of current row lImageHeight = lImageHeight - Grd.RowHeight(lThisRow) Exit For ElseIf lImageHeight + lTopBorder * 2 + lHeadingHeight > lPrinterPageHeight Then 'Allow the same border at the bottom and top 'Image is larger than page, subtract height of current row lImageHeight = lImageHeight - Grd.RowHeight(lThisRow) Exit For End If lRowsPerPage = lRowsPerPage + 1 Next 'Print this page lPagesPrinted = lPagesPrinted + 1 If lRowsToRepeat Then 'Print heading rows Printer.PaintPicture Grd.Picture, lLeftBorder, lTopBorder, , lHeadingHeight, , 0, , lHeadingHeight 'Print data rows Printer.PaintPicture Grd.Picture, lLeftBorder, lTopBorder + lHeadingHeight, , lImageHeight + lHeadingHeight, , lLastImageTop + lHeadingHeight, , lImageHeight + lHeadingHeight Else 'Print data rows Printer.PaintPicture Grd.Picture, lLeftBorder, lTopBorder, , lImageHeight, , lLastImageTop, , lImageHeight End If Printer.EndDoc 'Store printer position lRowsPrinted = lRowsPrinted + lRowsPerPage lLastImageTop = lLastImageTop + lImageHeight + lHeadingHeight Loop While lRowsPrinted < lNumRows FlexGridPrint = True Exit Function ErrFailed: 'Failed to print grid FlexGridPrint = False Debug.Print "Error in FlexGridPrint: " & Err.Description End Function
![]() |
Similar Threads
- Flex Grid,Data Report (Visual Basic 4 / 5 / 6)
- Showing data in vb flexgrid 4m a database (Visual Basic 4 / 5 / 6)
- VB6 - Programatically tell excel to print only the area that has data. (Visual Basic 4 / 5 / 6)
- Printing of Data not window on Client Sde (ASP.NET)
- Dumping printer command and data to a printer port (Windows NT / 2000 / XP)
- Displaying numeric data (Assembly)
- Print Screen (VB.NET)
- My yahoo client. Not receiving data in real time :(( Just need a bit of advice (Perl)
- Program Problem with a select statement to access Data base (C)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Point Of Sales Peripherals Connection..... can u help me plzzZz......
- Next Thread: how to print directly
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





