Home All Groups Group Topic Archive Search About

Problems using HasMorePages with oleDbDatareader

Author
16 Mar 2006 8:54 AM
Rave_T
Hi all!

I want to loop through my datareader and print out 5 rowns on each page
but i cant get it to work...
Heres my code:
Dim curr_X=20
Static intItem As Integer = 0
Dim y As Integer = 0
Dim bDraw As Boolean = True
Dim g As Graphics = e.Graphics
Do Until Not  bDraw
    myReader.Read
        e.Graphics.DrawString(myReader(1).toString, New Font("Verdana",
8, FontStyle.Regular), Brushes.Black, curr_X, rowHeight)
    curr_X=200+curr_X
    rowHeight=rowHeight+25
    y += 15
    g.DrawString(intItem.ToString, Me.Font, Brushes.Black, 10, y)
    intItem += 1
    bDraw = (intItem Mod 5 <> 0)
Loop
If intItem = 25 Then
    intItem = 0
Else
       e.HasMorePages = True
End If

The variable intItem have i just used to see if it works somehow and it
does, intItem is correctly put to 0-4 on page one and then 5-10 on page
two and so on, but the data from the datareader is the same on all
pages.....

Any ideas?

Author
16 Mar 2006 10:03 AM
Cor Ligthert [MVP]
Hi Rave,

There are more paging samples on our website for windowsforms grids.

http://www.vb-tips.com/default.aspx?ID=79afdb6a-611d-43cd-9186-def86a1baeef

I think that this one comes the closest to your question.

I hope this helps,

Cor

Show quoteHide quote
"Rave_T" <tobia***@spray.se> schreef in bericht
news:1142499295.891092.140130@j52g2000cwj.googlegroups.com...
> Hi all!
>
> I want to loop through my datareader and print out 5 rowns on each page
> but i cant get it to work...
> Heres my code:
> Dim curr_X=20
> Static intItem As Integer = 0
> Dim y As Integer = 0
> Dim bDraw As Boolean = True
> Dim g As Graphics = e.Graphics
> Do Until Not  bDraw
> myReader.Read
>        e.Graphics.DrawString(myReader(1).toString, New Font("Verdana",
> 8, FontStyle.Regular), Brushes.Black, curr_X, rowHeight)
> curr_X=200+curr_X
> rowHeight=rowHeight+25
> y += 15
> g.DrawString(intItem.ToString, Me.Font, Brushes.Black, 10, y)
> intItem += 1
> bDraw = (intItem Mod 5 <> 0)
> Loop
> If intItem = 25 Then
> intItem = 0
> Else
>       e.HasMorePages = True
> End If
>
> The variable intItem have i just used to see if it works somehow and it
> does, intItem is correctly put to 0-4 on page one and then 5-10 on page
> two and so on, but the data from the datareader is the same on all
> pages.....
>
> Any ideas?
>