mrozu Newbie
Joined: 06 Jun 2005 Posts: 2
|
Posted: Jul 21st, 2005 05:43 AM Post subject: Print headers DBGRID |
|
|
Hi
last time i made small application, which print data from DBGrid. Code:
| Code: | rinter.PrintQuality = -1
Printer.FontSize = 8
Dim i As Integer 'to be used for the for...next loop
Dim R As Integer 'to be used to increment the row number
Dim IncreaseY As Integer 'to be used to increase Y co-ordinate
ilosc = MSRDC1.Resultset.RowCount
Printer.ScaleMode = 6 'declare measurement units
'Print First Row
Printer.CurrentX = 5 'declare first position of X
Printer.CurrentY = 10 'declare first position of Y
DBGrid1.Col = 0 'identify column number to print
DBGrid1.Row = 0 'identify row number to print
Printer.Print DBGrid1.Text
Printer.Line (4, 10)-(4, 10 + MSRDC1.Resultset.RowCount * 5)
'
DBGrid1.Col = 1 'identify column number to print
Printer.CurrentX = 25 'declare new position of Y
Printer.CurrentY = 10 'declare position of Y
Printer.Print DBGrid1.Text
Printer.Line (24, 10)-(24, 10 + MSRDC1.Resultset.RowCount * 5)
DBGrid1.Col = 2 'identify column number to print
Printer.CurrentX = 60 'declare new position of Y
Printer.CurrentY = 10 'declare position of Y
Printer.Print DBGrid1.Text
Printer.Line (59, 10)-(59, 10 + MSRDC1.Resultset.RowCount * 5)
'
DBGrid1.Col = 3
Printer.CurrentX = 80
Printer.CurrentY = 10
Printer.Print DBGrid1.Text
Printer.Line (79, 10)-(79, 10 + MSRDC1.Resultset.RowCount * 5)
DBGrid1.Col = 4
Printer.CurrentX = 105
Printer.CurrentY = 10
Printer.Print DBGrid1.Text
Printer.Line (104, 10)-(104, 10 + MSRDC1.Resultset.RowCount * 5)
DBGrid1.Col = 5
Printer.CurrentX = 155
Printer.CurrentY = 10
Printer.Print DBGrid1.Text
Printer.Line (154, 10)-(154, 10 + MSRDC1.Resultset.RowCount * 5)
DBGrid1.Col = 6
Printer.CurrentX = 175
Printer.CurrentY = 10
Printer.Print DBGrid1.Text
Printer.Line (174, 10)-(174, 10 + MSRDC1.Resultset.RowCount * 5)
DBGrid1.Col = 7
Printer.CurrentX = 185
Printer.CurrentY = 10
Printer.Print DBGrid1.Text
Printer.Line (184, 10)-(184, 10 + MSRDC1.Resultset.RowCount * 5)
Printer.Line (203, 10)-(203, 10 + MSRDC1.Resultset.RowCount * 5)
'Print NINE more Rows, leave first row alone
For i = 1 To MSRDC1.Resultset.RowCount - 1 'or use DBGrid1.VisibleRows to print all the visible rows
R = R + 1 'row number by increase one with every loop
IncreaseY = IncreaseY + 5 'increaseY by 5 with every loop
'
On Error Resume Next
DBGrid1.Row = R 'identify row number to print
If Err.Number = 6148 Then
Data1.Recordset.MoveNext
End If
'identify row number to print
Printer.CurrentX = 5 'declare same position of X
Printer.CurrentY = 10 + IncreaseY 'declare position of Y
DBGrid1.Col = 0 'identify column number to print
Printer.Print DBGrid1.Text
'
DBGrid1.Col = 1 'identify column number to print
Printer.CurrentX = 25 'declare new position of Y
Printer.CurrentY = 10 + IncreaseY 'declare position of Y
Printer.Print DBGrid1.Text
DBGrid1.Col = 2 'identify column number to print
Printer.CurrentX = 60 'declare new position of Y
Printer.CurrentY = 10 + IncreaseY 'declare position of Y
Printer.Print DBGrid1.Text
Printer.Line (59, 10)-(59, 10 + ilosc * 5)
'
DBGrid1.Col = 3
Printer.CurrentX = 80
Printer.CurrentY = 10 + IncreaseY
Printer.Print DBGrid1.Text
Printer.Line (79, 10)-(79, 10 + ilosc * 5)
DBGrid1.Col = 4
Printer.CurrentX = 105
Printer.CurrentY = 10 + IncreaseY
Printer.Print DBGrid1.Text
Printer.Line (104, 10)-(104, 10 + ilosc * 5)
DBGrid1.Col = 5
Printer.CurrentX = 155
Printer.CurrentY = 10 + IncreaseY
Printer.Print DBGrid1.Text
Printer.Line (154, 10)-(154, 10 + ilosc * 5)
DBGrid1.Col = 6
Printer.CurrentX = 175
Printer.CurrentY = 10 + IncreaseY
Printer.Print DBGrid1.Text
Printer.Line (174, 10)-(174, 10 + ilosc * 5)
DBGrid1.Col = 7
Printer.CurrentX = 185
Printer.CurrentY = 10 + IncreaseY
Printer.Print DBGrid1.Text
Printer.Line (184, 10)-(184, 10 + ilosc * 5)
Printer.Line (203, 10)-(203, 10 + ilosc * 5)
Next i
Dim j As Integer 'to be used to draw horizontal line
Dim Counter As Integer 'to increase the value of Y
For j = 1 To MSRDC1.Resultset.RowCount + 1
Counter = Counter + 5
Printer.Line (4, 5 + Counter)-(203, 5 + Counter)
Next j
Printer.EndDoc
End Sub |
but this print only data, not headers. And now i have question how modify this code, in order to print headers??
Thx[/code] _________________ GG :1718352
POLAND |
|