方法一
private ArrayList GetCheckedItemsText(CheckedListBox lst_items) { ArrayList result = new ArrayList(); IEnumerator myEnumerator; myEnumerator = lst_items.CheckedIndices.GetEnumerator(); int index;
while (myEnumerator.MoveNext() != false) { index = (int)myEnumerator.Current; lst_items.SelectedItem = lst_items.Items[index]; result.Add(lst_items.Text); }
return result; }
方法二:
foreach (ListItem li in this.checklistbox1) { if (li.Selected = true) { excelstr += li.ToString() + ", "; } } if (excelstr[excelstr.Length - 1].ToString() == ", ") { excelstr = excelstr.Substring(0, excelstr.Length - 1); } this.message.Text = excelstr;
另可参考:http://social.msdn.microsoft.com/Forums/ro-RO/visualcshartzhchs/thread/f811016c-3ae3-4211-894a-c9054db5dfd6