ComboBox值排序

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]);
}

posted on 2013-08-27 14:49  重新开始js  阅读(2890)  评论(0编辑  收藏  举报

导航