ComboBox值排序
先是想通过冒泡排序,但是冒泡排序是int类型,又打算通过下标,进行字符串排序,然后想到了一个简单的办法……
先存入ArrayList排序Sort清空ComboBox再遍历存入ComboBox很简单的几行代码搞定
ArrayList al =new ArrayList();
for (int i = 0; i < combobox.Items.Count; i++)
{
string a = combobox.Items[i].ToString();
al.Add(a);
}
al.Sort();
combobox.Items.Clear();
for (int i = 0; i < al.Count; i++)
{
combobox.Items.Add(al[i]);
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-10
  • 2022-12-23
  • 2021-12-08
  • 2022-12-23
  • 2021-10-15
  • 2021-12-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2022-12-23
相关资源
相似解决方案