Print Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Diogo Alves - Software Developer

    Print Question

    Hi,

    I am trying to build a preview of a document that I am doing...

    To do it I am using a ODBCConnection and drawing a table with GDI+

    The problem is that I only want 5 rows per page...
    so I did this
    for int j = 0; j<col;j++
    {
    currentRow++;
    if (currentRow == 5)
    {
    currentRow = 0;
    currentPage++;
    e.HasMorePages = true;
    }
    ...........
    }

    it goes into a loop and when I cancell all the pages have the same
    information on it...
    How can I solve this?
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Print Question

    Diogo,

    You shouldn't check to see if the current row is equal to five. Rather,
    check to see that the row is not 1 (assuming you start at 0 for your row
    indexer, which you should, see example), and then if the current row doesn't
    have a remainder of 1 when you divide by five (the checks are against 1
    because you are incrementing the current row number before you perform your
    check), you indicate that you have more pages. Something like this:

    // Current row is 0. This and the current page variable
    // is defined outside of your event handler.
    int currentRow = 0;

    // Process the current row on the current page.
    ...

    // Increment the current row.
    currentRow++;

    // Perform the check here.
    if ((currentRow % 0) == 1 && currentRow != 1 && currentRow != rowCount)
    {
    // Increment the current page count.
    currentPage++;

    // Indicate that there are more pages.
    e.HasMorePages = true;

    // Exit the event handler.
    return;
    }

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Diogo Alves - Software Developer"
    <DiogoAlvesSoft wareDeveloper@d iscussions.micr osoft.com> wrote in message
    news:BB98D978-B2BC-454A-8BD0-ACB40995F629@mi crosoft.com...[color=blue]
    > Hi,
    >
    > I am trying to build a preview of a document that I am doing...
    >
    > To do it I am using a ODBCConnection and drawing a table with GDI+
    >
    > The problem is that I only want 5 rows per page...
    > so I did this
    > for int j = 0; j<col;j++
    > {
    > currentRow++;
    > if (currentRow == 5)
    > {
    > currentRow = 0;
    > currentPage++;
    > e.HasMorePages = true;
    > }
    > ..........
    > }
    >
    > it goes into a loop and when I cancell all the pages have the same
    > information on it...
    > How can I solve this?[/color]


    Comment

    Working...