Problems using HasMorePages with oleDbDatareader

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rave_T

    #1

    Problems using HasMorePages with oleDbDatareader

    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.Draw String(myReader (1).toString, New Font("Verdana",
    8, FontStyle.Regul ar), Brushes.Black, curr_X, rowHeight)
    curr_X=200+curr _X
    rowHeight=rowHe ight+25
    y += 15
    g.DrawString(in tItem.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?

  • Cor Ligthert [MVP]

    #2
    Re: Problems using HasMorePages with oleDbDatareader

    Hi Rave,

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



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

    I hope this helps,

    Cor

    "Rave_T" <tobias_k@spray .se> schreef in bericht
    news:1142499295 .891092.140130@ j52g2000cwj.goo glegroups.com.. .[color=blue]
    > 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.Draw String(myReader (1).toString, New Font("Verdana",
    > 8, FontStyle.Regul ar), Brushes.Black, curr_X, rowHeight)
    > curr_X=200+curr _X
    > rowHeight=rowHe ight+25
    > y += 15
    > g.DrawString(in tItem.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?
    >[/color]


    Comment

    Working...