【发布时间】:2012-03-14 14:33:48
【问题描述】:
我有带有多选模式的 Listbox1。 Now i want, when items in that Listbox are selected to pass them on next form.列表框在表单 1 上,单击表单 2 旁边的按钮以在表单 2 上的标签中向我显示列表框表单 1 中选择了哪些项目。
试过了
foreach (var item in listBoxSobe.SelectedItems)
{
lblSobe.Text += (lblSobe.Text == "" ? "" : ", ") + item.ToString();
}
但结果我得到 "System.Data.DataRowView.." ,而不是从列表框中单击项目
【问题讨论】:
-
因为您传递的是对象而不是值。尝试添加 strItem = item.ToString();并将 strItem 传递给 lblSobe.text 而不是 item
-
@Brian 这是因为项目的类型是
DataRowView,而不是因为传递了对象。