如何apach foreach循环 [英] how aply foreach loop
本文介绍了如何apach foreach循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
如何在Windows窗体中应用每个循环到复选框列表应用程序在Visual Studio 2012中
我正在使用C#
hi
how to Apply for each loop to checkedbox list in windows form Application in visual studio 2012
Im using C#
推荐答案
参考此演示代码块
Refer this demo code block
List<ListItem> selected = new List<ListItem>();
foreach (ListItem item in CBLGold.Items)
if (item.Selected) selected.Add(item);
不清楚那么多。
但是,如果你在谈论一个简单的List< checkbox>然后,
Not clear that much.
But, if you are talking about a simple List<checkbox> then,
List<CheckBox> cbList = new List<CheckBox>();
foreach(CheckBox cb in cbList)
{
//do what you want here.
cb.Checked = true;
}
问候。
Regards.
看在项目属性 [ ^ ]:
Look at the Items Property[^]:
foreach (object o in myCheckedListBox.Items)
{
Console.WriteLine(o.ToString());
}
或者使用 CheckedItems属性 [ ^ ]。
这篇关于如何apach foreach循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文