在检查列表框中创建检查项目的字符串数组 [英] Creating a string-array of checked items in checked-list-box

查看:66
本文介绍了在检查列表框中创建检查项目的字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用foreach循环(或任何其他方式)创建一个包含检查列表框中检查项目的数组?

How can I create an array containing the checked items in a checkedlistbox using foreach loop (or any other way)?

我不知道列表中的项目数.

I can't know the number of items in the list.

推荐答案

假设您使用的是3.5或更高版本.

Assuming your using 3.5 or above..

object[] items = lb.CheckedItems.OfType<object>().ToArray();

如果要在CheckedListBox中添加特定类型的对象,则可以使用所用类的名称替换对象.

And if you are adding a specific type of object to the CheckedListBox then you can replace object with the name of the class you use.

这篇关于在检查列表框中创建检查项目的字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆