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.
The focus is on the PrintPage event, which has a HasMorePages property. If this property is true, he will open a new page and execute the custom event bound to PrintPage again. So it is equivalent to a recursion, you need to return this method at the right time. Finally, set HasMorePages to false so it won't recycle.
Related
I am new to WPF. I am making an windows app which will scan a QR-code, divide its contents into multiple parts and display them under several columns as below.
e.g. (in the picture attached)
example
When a QR-code is scanned repeatedly, the Qty field is increased by 1 each time.
Can any one help me how to achieve this in my application.
(I have used datagridviews and dynamic labels in winforms, but in WPF the best recommended way?)
First of all, how does the data arrive from your scanner? Is it an array? Or a List?
If it's an array you can easily add a new column to the grid which receives an increment value (f.e. "x++") every repeat of a foreach loop. If you upload a few code snippets I will try to tinker something.
I am with a little issue on handling with one of my applications.
I have a Vessel's historic which is shown on a ListView, but until now I have never needed to show all the data inside this history (the user was using kind of a filter to get what he needed), but now one of the managers want to see all data through the application (they was receiving the full data through an excel report).
The biggest issue is because its 6000 rows with 21 columns each one and when I try to select all the data it takes something between 5 minutes to fully load, but more than that the user need to add new, edit or copy the history, which brings him to a new update on the list with more 5 minutes to load.
I don't quite know how is the best way to handle with this and I wanted your help!
I would actually split the information into sections. Rather than loading 6,000 rows plus columns all at once, why don't you use something like alphabetize the information? Use a different ListView for A-G, then another ListView for H-O, then so on and so forth. That why it would cut down the time it took to query all of the information.
I like to have 2 lines (rows) in datagrid, which is together. So normally in a grid you have 1 line per row and every next line/row is independent... But I like to have 2 lines. e.g. 1st row the name,address and 2nd line some amounts, or dates.... so every 2 line is together..
what control do I need to use in Winforms to achieve this... I'm newbie, so I prefer simple solution...
e.g. below I like to use (amount fields should be shown on next line in Datagrid)
DocNumber DocType DueDate SupplierNo SupplierName
Amount VATAmount Total Amount
10000 SA 01-05-2012 1025 Supplier-A
12.25 0.25 12.25
10001 SA 12-12-2014 1095 Supplier-B
42.25 5.25 47.00
10002 SB 31-11-2012 1099 Supplier-C
152.25 55.25 192.00
You could add an extra column to your data (i.e DataTable, for instance) where you specify the row order, and then hide it in your control (a DataGridView for instance).
However this has several drawbacks the first one that comes to mind is that if you click on column headers to sort the grid contents, it will not preserve the order of your rows.
Hope this helps.
Well sounds like to me you need to "group" your data if that's what I'm reading right.
However if this is the case I'm afraid Winforms DGVs do not support this as default as far as my understanding is.
I found this link but havent tried it, looks to be a possible work around/hack for it.
Group Functionality for Winforms Datagridviews
On the plus side there are alot of 3rd party options such as:
Telerik Controls
Or my Personnel favorite :
DevExpress Controls
Beware though even though u can do trials, You may have to pay for publishing, but worth a look!
Hope this helps!
I have a page that is currently generating dynamically created textboxes in a table format. The users are requesting that the tab order be changed from horizontal-vertical to vertical-horizontal. I know that you can use the tabindex attribute to control the tab ordering, but I can't for the life of me figure out the right way to get the sequential number properly for the textboxes. I guess this is more of a math question than anything else!
FYI, the textboxes are made while looping two different collections. First collection looped to make the rows, for each row, second collection (which is a property of the first collection objects) is looped to create the columns.
Any help would be greatly appreciated. Thanks!
You will need three variables to get this to work:
Total number of rows
Current row index
Current column index
You can then achieve the vertical tab order by setting the tabindex to:
totalRowCount * currentColumnIndex + currentRowIndex + 1
For a five-row, three-column table the above calculation would render the tab order as:
1 5 10
2 6 11
3 7 12
4 8 13
5 9 14
Updated: Wil, thanks for pointing that out. I've updated the example. I also checked the W3C spec (which I probably should have done first) which clarifies the behavior:
elements that do not support the
tabindex attribute or support it and
assign it a value of "0" are navigated
next. These elements are navigated in
the order they appear in the character
stream.
How can I set the pagination or the number of items being displayed in a single page? Suppose there are 1000 items and at each page I want to show 100 and use a next button to navigate to the next page . How can I be able to do that, Please discuss it in c# context .
Thank You.
You can do this by using PageBreaks.
From MSDN:
Page Breaks
In some reports, you may want to place
a page break at the end of a specified
number of rows instead of, or in
addition to, on groups or report
items. To do this, create a group in a
data region (typically a group
immediately outside the detail), add a
page break to the group, and then add
a group expression to group by a
specified number of rows.
The following expression, when placed
in the group expression, assigns a
number to each set of 25 rows. When a
page break is defined for the group,
this results in a page break every 25
rows.
=Int((RowNumber(Nothing)-1)/25)
Taken from http://msdn.microsoft.com/en-us/library/ms251668(VS.80).aspx