日期:2014-05-17 浏览次数:20788 次
string[] checkboxSelected = this.panel1.Controls.OfType<CheckBox>().Where(a => a.Checked).Select(a=>a.Text).ToArray();
list<string> names....
foreach (Control ctl in this.Controls)
{
CheckBox ckb = ctl as CheckBox;
if (ckb != null && ckb.Checked)
{
names.Add(ckb.Name);
}
}
IList<string> list = new List<string>();
foreach (var item in this.Controls)
{
if (item is CheckBox)
{
CheckBox cb = item as CheckBox;
list.Add(cb.Name);