Click here to Skip to main content
15,900,818 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,
I hope someone can point me in the right direction.
I have a list box that can have a different number of items in it.
I'm using this list box to create a text file tat is used for printing but I can only print 4 items on the page at a time so if the contents of the list box is creater than 4 I need to move the rest to the next page and so on and again if there are more than eight items the next 4 have to go onto a third page. The list will not always be a mutiple of 4. It could have 2, 3,4,5,6,7 etc items its just that I have to split it after every 4. Also each item gets a different location on the page and this is repeated after every 4 items.
I do not have any code yet as I've been racking my brain trying to figure out how to do this.
If anyone can help it would be great

Thanks in advance
J
Posted
Comments
ZurdoDev 14-Jan-16 12:10pm    
I would think it will depend on how you are printing the document. If you have code for that you can control where things go.
johnjsm 15-Jan-16 3:19am    
I'm using ZPL code for printing to a label printer. This allows you to give co-ordinates of where each item should be printed. You can also specify the beginning and end of a label.
ZurdoDev 15-Jan-16 7:29am    
If you can specify the coordinates, where are you stuck exactly?
johnjsm 15-Jan-16 8:48am    
1st item gets 1st coordinate
2nd item get 2nd coordinate
3rd item get 3rd coordinate
4th item get 4th coordinate
This is no problem. but when I go above 4 items I need to start back
5th item gets 1st coordinate
6th item get 2nd coordinate
7th item get 3rd coordinate
8th item get 4th coordinate
Aslo need to figure out that at the start and finish of each 4 items I need to put the code for start and finish of the label
ZurdoDev 15-Jan-16 9:02am    
Yes, when you get to 4 you reset your variables so you can start back again.

1 solution

Please, read all comments.

Start here: How to: Print a Multi-Page Text File in Windows Forms[^]

To achieve what you want to get, you should write for - next loop this way:
VB.NET
Dim j As Integer = 1
For i As Integer = 0 To 49
    If i Mod 4 = 0 Then j = 1
    Console.WriteLine("item: {0} coordinate: {1}", i, j)
    j +=1
Next

Result:
item: 0 coordinate: 1
item: 1 coordinate: 2
item: 2 coordinate: 3
item: 3 coordinate: 4
item: 4 coordinate: 1
item: 5 coordinate: 2
item: 6 coordinate: 3
item: 7 coordinate: 4
item: 8 coordinate: 1
item: 9 coordinate: 2
item: 10 coordinate: 3
item: 11 coordinate: 4
item: 12 coordinate: 1
item: 13 coordinate: 2
item: 14 coordinate: 3
item: 15 coordinate: 4
item: 16 coordinate: 1
item: 17 coordinate: 2
item: 18 coordinate: 3
item: 19 coordinate: 4
item: 20 coordinate: 1
item: 21 coordinate: 2
item: 22 coordinate: 3
item: 23 coordinate: 4
item: 24 coordinate: 1
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 15-Jan-16 21:56pm    
Sure, a 5.
—SA
Maciej Los 16-Jan-16 14:40pm    
Thank you, Sergey.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900