且构网

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

选择列表框的项目,它匹配字符串数组的项目

更新时间:2023-11-15 15:13:04

查看此修改后的代码。



Check this modified code.

string str1 = myReader["Books"].ToString();
string[] arr = str1.Split(',');
foreach (string word in arr)
{
  int index = listbox1.FindString(word)
  if (index != -1 )
  {
     listBox1.SelectedItems.Add(word);
  }
 
  }
};





了解更多关于ListBox.FindString @的信息 MSDN [ ^ ]