【发布时间】:2019-10-08 13:26:02
【问题描述】:
listbox1 中显示以下数据。我想将项目从 listbox2 传递到 listbox1。结果应该如下图所示(lb1)。如何实现? 非常感谢您的帮助!
var itm = listBox2.Items[0].ToString();
listBox1.Items.Add(itm);
【问题讨论】:
-
你想要一份参考资料(项目的纠缠)还是列表的副本?
-
listbox1 中的每一项都用逗号分隔。我想将 listbox2 中的项目附加到同一行中的前一个项目(不是彼此之间)。
-
你的意思是这样吗?
string firstLine = listBox1.Items[0] as string; if (string.IsNullOrEmpty(firstLine)) listBox1.Items[0] = itm; else listBox1.Items[0] += "," + itm;? -
正确!那行得通!非常感谢,“mm8” :)