Reputation: 131
I am writing a C# WinForms app, and part of it includes generating inventory reports. I can't print the inventory one item per line, because each inventory item may be located in more than one location. So, the goal is to print the name of the product (and a few other details) one one line, and below it, print a list of locations where the item is located and how many should be in each location, basically like this:
WIDGET (ACME, INC) PRODUCT #123435 TOTAL ON HAND: 30
Aisle: 10 Count: 15
Aisle: 4 Count: 6
Aisle: 15 Count: 9
SNIPE (ACE SNIPE CO) PRODUCT #67890 TOTAL ON HAND: 11
Aisle: 1 Count: 4
Aisle: 3 Count: 7
and so on...
The problem I'm running into is, to print this requires a loop within a loop - the outer loop is the list of products, and the inner loop is the list of locations and counts for each product. What I can't figure out is how to cause a page break when I am inside the inner loop and hit the bottom of the page. What needs to happen is for the printing routine to print a new page header but then pick up where it left off in the list of locations for the product it was printing.
The printing code I've written works well except I can't figure out how to catch hitting the bottom of the page to start a new page while inside the inner loop[, so the printing runs off the bottom of the page.
So the question is, when you have a loop inside another loop while printing, how do you check page position and start a new page that continues where you left off? I'd be glad to provide the code I have for this so far, but I thought the explanation of the problem might be easier for people to understand and provide some guidance on. I have been banging my head against the wall on this for a couple days, and nothing I've found anywhere on the web addresses this.
Thanks for any help that is given.
Upvotes: 1
Views: 172