【发布时间】:2013-08-27 10:59:40
【问题描述】:
如何将 2 个 listBox 中的项目添加到一个 listBox?
例如:listBox1 包含 Hello listBox2 包含 World!因此,如果在 listbox3 中单击 button1 将显示 Hello World!并排,但不是像新行一样
你好
世界!
private void button2_Click(object sender, EventArgs e)
{
listBox3.Items.Add(listBox1.Items + listBox2.Items);
}
【问题讨论】:
-
你的
listBox1和listBox2有多少Items? -
取决于不包含特定数字的列表。
-
那么,您想正确添加相同的索引项吗?比如
listBox1.Items[0] + listBox2.Items[0]、listBox1.Items[1] + listBox2.Items[1]等等……? -
我想让它像这样 ex:listbox1 包含 3 个单词,listbox2 有 1 个单词,因此输出将是 listbox1 上的每个单词将与 listbox2 结合。
-
在你的情况下,你想要
listBox3中的全部 4 个词还是只需要 2 个词(listbox1的第一个词 +listbox2的第一个词)?