简体   繁体   English

如何在vb.net中将项目添加到列表框中的另一个

[英]How can I add items to listbox one under the other in vb.net

Hi I am doing shopping list and I want to list the items one under the other 嗨,我正在购物清单中,我想列出一个项目在另一个项目下

ListBox1.Items.Add(shp.fruits & vbNewLine & shp.vegetables & vbNewLine & shp.drinks & vbNewLine & shp.snacks & vbNewLine & shp.detergent)

this is my code but writes items next each other without space 这是我的代码,但彼此紧紧地写项目

You can not insert line breaks in a ListBox . 您不能在ListBox插入换行符。
Every item added will be one line. 添加的每一项将是一行。

If you want to add a range of items, try this instead: 如果要添加一系列项目,请尝试以下操作:

ListBox1.Items.AddRange({shp.fruits, shp.vegetables, shp.drinks, shp.snacks, shp.detergent})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM