Read Before you use
While using
MSHFlex Grid you must set colwidth to each
column. Default colwidth do not work with this.
If you make rowheight smaller than the text height, it looks ok
in picture box or form but does not print ok, the text will be
printed over the cell one below that.
Only bmp pictures are allowed, PixHeight and PixWidth must be set
for picture that size other than 32X32 pixels.
Some properties and methods those need explanation.
bLastRowPrinted
[boolean] When the last row of MSHflex is printed, this turns
True. This is useful when printing multiple pages. For e.g.
...
...
Do While Not M.bLastRowPrinted
M.SetRowsEven
M.PrintOut Form1
Loop
...
...
ColSetUpCode
To quickly copy the code required to set up the colwidth of
flexgrid control, slide every column of flexgrid and issue this
method, the required code will be copied to the clipboard.
CurX and CurY
This is CurrentX and CurrentY
DrawEmptyCell
Enable/Disable drawing empty cells, if it is set to False, cells
with no picture or text will not be drawn.
LastRowPrinted
[Long] Returns or sets the value of last row printed in each page.
PixHeight and PixWidth
Set the height and width of picture if the pictures have height
and width other than default, the default height and width is 32X32
pixels.
RowsPerPage
The number of rows to be printed in each page. This value is used
only by SetRowsEven method. This method set values to RowTo and
RowFrom properties.
SetRowsEven (FirstPage
as boolean)
This mehod prints several pages, rows in each page=RowPerPage+1
FirstPage: if printing first page set it to True and for the rest
of the pages set it to False. But this value is required only in
some special cases, just ignor it.
Following example shows how to print more than one page when rows
are uniform sized.
Printer.ScaleMode = vbTwips
Printer.PaperSize = vbPRPSA5
Printer.Orientation = vbPRORLandscape
With M
.RowsPerPage = 10
.LastRowPrinted = -1
.DrawBorder = True
.PosTop = Printer.ScaleY(800, vbTwips, vbPixels)
.PosLeft = Printer.ScaleX(800, vbTwips, vbPixels)
Do
While Not .bLastRowPrinted
.SetRowsEven
.PrintOut Printer
Printer.NewPage
Loop
Printer.EndDoc
.bLastRowPrinted = False
End
With
Printer.EndDoc
[ for more samples about how to print with
header and footer in each page and how to keep first row in each
page, visit http://geocities.com/opalraj/vb ]
SetRowsUneven (Paperheight_In_Twips
As Long, FirstPage As Boolean)
This method is used to determine the number of rows when freedom
of changing the rowheight is given to user. If the rowheights are
uncertain or uneven then this method is used in place of
SetRowsEven method.
Paperheight_In_Twips: Supply the paper height, note that the max
rowheight must be less than paper height.
FirstPage: if printing first page set it to True and for the rest
of the pages set it to False.
Example
Dim PrnScaleHt As Long
Dim bFpage As Boolean
bFpage = True
Printer.ScaleMode = vbTwips
Printer.PaperSize = vbPRPSA5
Printer.Orientation = vbPRORLandscape
PrnScaleHt = Printer.ScaleHeight - 1000 ' Reduce the value of
PosTop + a bit
With M
.LastRowPrinted = 0
.PosTop = Printer.ScaleY(800, vbTwips, vbPixels)
.PosLeft = Printer.ScaleX(800, vbTwips, vbPixels)
.DrawBorder = True
Do While Not .bLastRowPrinted
.SetRowsUneven PrnScaleHt, bFpage
.PrintOut Printer
Printer.NewPage
bFpage = False
Loop
.bLastRowPrinted = False
End With
Printer.EndDoc
[ for more samples about how to print with header and footer in
each page and how to keep first row in each page, visit http://geocities.com/opalraj/vb ]
Do send me your comment, feedback, improvement
or suggestion.
Opal R Ghimire,
Kathmandu, Nepal
buna48@hotmail.com