帮助代码通过列表框 [英] Help with code to go through list box

查看:82
本文介绍了帮助代码通过列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我希望有人能指出我正确的方向。

我有一个列表框可以包含不同数量的项目。

我正在使用此列表框创建一个文本文件,用于打印但是我一次只能在页面上打印4个项目,所以如果列表框的内容比4更好,我需要将其余部分移到下一页,依此类推,如果有超过8个项目则接下来4个进入第三页。列表并不总是4个多。它可以有2个,3,4,5,6,7个等项目,我必须在每个4之后拆分它。此外,每个项目在页面上都有不同的位置,每4个项目后重复一次。

我还没有任何代码,因为我一直绞尽脑汁试图弄清楚如何做到这一点。

如果有人可以帮助它会很棒



提前致谢

J

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

推荐答案

请阅读所有评论。



从这里开始:如何:在Windows窗体中打印多页文本文件 [ ^ ]



达到你想要的效果要得到,你应该这样写 - 下一个循环:

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:
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


这篇关于帮助代码通过列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆