H
Hector M Banda
Hi all,
Need i simple example on how print/preview data from a database.
I already have some code but I am lost because the preview does not create
multiple pages and only shows the first page and the printing goes over the
margins of the page. My problem is that I cannot figure out how to control
new page when page is getting full. Another problem is that I would like to
have a common place to set headers and footers to be printed every time a
new page is sent.
I would like to have a little code sample even with just printing lines.
This is part of the code that I am using with MySQL database just going thru
some records:
While datareader.Read()
e.Graphics.DrawString(datareader("upc").ToString, sfont, Brushes.Black,
lblpos(0) + 0.5, YPosition)
e.Graphics.DrawString(datareader("description").ToString, sfont,
Brushes.Black, lblpos(1) + 0.5, YPosition)
e.Graphics.DrawString(datareader("onhand").ToString, sfont, Brushes.Black,
lblpos(2) + 0.5, YPosition)
e.Graphics.DrawString(datareader("min").ToString, sfont, Brushes.Black,
lblpos(3) + 0.5, YPosition)
e.Graphics.DrawString(datareader("cost").ToString, sfont, Brushes.Black,
lblpos(4) + 0.5, YPosition)
e.Graphics.DrawString(datareader("price").ToString, sfont, Brushes.Black,
lblpos(5) + 0.5, YPosition)
CountLine += 1
YPosition = TopMargin + (CountLine * myFont.GetHeight(e.Graphics))
Console.WriteLine(">>>" & YPosition)
If CountLine = 20 Then
e.HasMorePages = False
CountLine = 1
Else
e.HasMorePages = True
End If
End While
datareader.Close()
Some of the code has been omitted.
Thanks,
-hb
Need i simple example on how print/preview data from a database.
I already have some code but I am lost because the preview does not create
multiple pages and only shows the first page and the printing goes over the
margins of the page. My problem is that I cannot figure out how to control
new page when page is getting full. Another problem is that I would like to
have a common place to set headers and footers to be printed every time a
new page is sent.
I would like to have a little code sample even with just printing lines.
This is part of the code that I am using with MySQL database just going thru
some records:
While datareader.Read()
e.Graphics.DrawString(datareader("upc").ToString, sfont, Brushes.Black,
lblpos(0) + 0.5, YPosition)
e.Graphics.DrawString(datareader("description").ToString, sfont,
Brushes.Black, lblpos(1) + 0.5, YPosition)
e.Graphics.DrawString(datareader("onhand").ToString, sfont, Brushes.Black,
lblpos(2) + 0.5, YPosition)
e.Graphics.DrawString(datareader("min").ToString, sfont, Brushes.Black,
lblpos(3) + 0.5, YPosition)
e.Graphics.DrawString(datareader("cost").ToString, sfont, Brushes.Black,
lblpos(4) + 0.5, YPosition)
e.Graphics.DrawString(datareader("price").ToString, sfont, Brushes.Black,
lblpos(5) + 0.5, YPosition)
CountLine += 1
YPosition = TopMargin + (CountLine * myFont.GetHeight(e.Graphics))
Console.WriteLine(">>>" & YPosition)
If CountLine = 20 Then
e.HasMorePages = False
CountLine = 1
Else
e.HasMorePages = True
End If
End While
datareader.Close()
Some of the code has been omitted.
Thanks,
-hb