且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在添加/更新列表框中的项目时出现错误

更新时间:2023-11-28 18:34:10

按照以下方式尝试


try this in the Following way


 foreach (ListItem item in ListBox1.Items)
           {
               strc += item + ",";
           }


//You are taking string for ListBox items instead of list Item


像这样对您有用

Do it like that it should work for you

listBox1.Items.Cast<object>().Aggregate((item1, item2) => item1 + "," + item2).ToString();
</object>



在您的代码中,问题出在这里



In your code the problem is here

foreach (string itm in listBox1.Items)