C#中获取CheckListBox选中项的值

        /// <summary>
        /// C#中获取CheckListBox选中项的值。
        /// </summary>
        /// <param name="clb">要被获取选中项的CheckListBox类型的对象。</param>
        /// <returns>返回一个ArrayList类型的对象。</returns>
        private ArrayList GetCheckedItemsText(CheckedListBox clb)
        {
            ArrayList result = new ArrayList();
            IEnumerator myEnumerator = clb.CheckedIndices.GetEnumerator();
            int index;

            while (myEnumerator.MoveNext())
            {
                index = (int)myEnumerator.Current;
                clb.SelectedItem = clb.Items[index];
                result.Add(clb.Text);
            }
            return result;
        }

posted @ 2011-03-10 09:08  瑞恩多芬  阅读(7023)  评论(0编辑  收藏  举报