Hello VbForums
I use Krool's VbFlexgrid .
On the form it shows Right to left
I mean the "record Name " in the first column.
but when I print , it is sorted Left to Right.
The "record Name " is in the last column.
this is the function I use
Code:
Private Sub PrintFlexGrid(ByVal ptr As Object, ByVal flx As VBFlexGrid, ByVal xmin As Single, ByVal ymin As Single)
Const GAP = 60
Dim xmax As Single
Dim ymax As Single
Dim x As Single
Dim c As Integer
Dim r As Integer
With ptr.Font
.Name = VBFlexGrid1.Font.Name
.Size = VBFlexGrid1.Font.Size
End With
With VBFlexGrid1
' See how wide the whole thing is.
xmax = xmin + GAP
For c = 0 To .Cols - 1
xmax = xmax + .ColWidth(c) + 2 * GAP
Next c
' Print each row.
ptr.CurrentY = ymin
For r = 0 To .Rows - 1
' Draw a line above this row.
If r > 0 Then ptr.Line (xmin, ptr.CurrentY)-(xmax, ptr.CurrentY)
ptr.CurrentY = ptr.CurrentY + GAP
' Print the entries on this row.
x = xmin + GAP
For c = 0 To .Cols - 1
ptr.CurrentX = x
ptr.Print BoundedText(ptr, .TextMatrix(r, c), .ColWidth(c));
x = x + .ColWidth(c) + 2 * GAP
Next c
ptr.CurrentY = ptr.CurrentY + GAP
' Move to the next line.
ptr.Print
Next r
ymax = ptr.CurrentY
' Draw a box around everything.
ptr.Line (xmin, ymin)-(xmax, ymax), , B
' Draw lines between the columns.
x = xmin
For c = 0 To .Cols - 2
x = x + .ColWidth(c) + 2 * GAP
ptr.Line (x, ymin)-(x, ymax)
Next c
End With
End Sub
'Usage
Code:
On Error Resume Next
Dim Row As Long
Dim Col As Long
With VBFlexGrid1
For Row = 0 To .Rows - 1
For Col = 0 To .Cols - 1
.Col = Col
.Row = Row
.CellBackColor = vbWhite
Next
Next
End With
PrintFlexGrid Printer, VBFlexGrid1, 400, 400
Printer.EndDoc
End Sub
Any trick please?