checkboxlistcontrol使用
2012-08-29 12:05
197 查看
checkedListBoxControl1使用和listbox等控件相似,但还是有些区别的
1.绑定值:
List<CategoryInfo> modelList = new List<CategoryInfo>();
foreach (string str in result)
{
string[] modelStr = str.Split('-');
modelList.Add(new CategoryInfo() { ID = modelStr[0], Title = modelStr[1] });
}
checkedListBoxControl1.ValueMember = "";
checkedListBoxControl1.DisplayMember = "";
checkedListBoxControl1.DataSource = modelList;
2.取值:
因为使用datasource绑定的值,所以checkedListBoxControl1.items.cout是0.取不到值的,只能用下面的方法来获取
int i = 0;
while (checkedListBoxControl1.GetItemValue(i) != null)
{
if (checkedListBoxControl1.GetItemChecked(i) == true)
{
CheckBook.Add((checkedListBoxControl1.GetItem(i) as CategoryInfo));
}
i++;
}
1.绑定值:
List<CategoryInfo> modelList = new List<CategoryInfo>();
foreach (string str in result)
{
string[] modelStr = str.Split('-');
modelList.Add(new CategoryInfo() { ID = modelStr[0], Title = modelStr[1] });
}
checkedListBoxControl1.ValueMember = "";
checkedListBoxControl1.DisplayMember = "";
checkedListBoxControl1.DataSource = modelList;
2.取值:
因为使用datasource绑定的值,所以checkedListBoxControl1.items.cout是0.取不到值的,只能用下面的方法来获取
int i = 0;
while (checkedListBoxControl1.GetItemValue(i) != null)
{
if (checkedListBoxControl1.GetItemChecked(i) == true)
{
CheckBook.Add((checkedListBoxControl1.GetItem(i) as CategoryInfo));
}
i++;
}
相关文章推荐
- VC 6.0 MFC ListControl 控件的使用
- 使用了scriptmanager,同时用了CheckBoxList,实现CheckBoxList单选
- 使用JavaScript实现CheckBoxList单选两种方法
- ASP.NET DEMO Ⅳ : 使用数据源控件将数据绑定到 ListControl 上
- List Control控件中及时捕获checkbox被选中的消息的解决方案
- struts2 CheckBoxList使用时要注意的问题
- MFC中ListControl控件的使用
- yii2 checkboxlist使用及数据入库
- MFC控件使用说明(combo box Button Check Box Radio Button List Control Edit Box Hot Key IP Address....)
- 数据绑定应该使用 BindingSource 类 而不是使用ListControl.databingding
- 使用ASP.NET AJAX Control Toolkit中的ReorderList控件实现用鼠标拖动改变条目顺序
- MFC ListControl控件使用InsertItem()函数插入新的列表项后不能显示列表项名称
- checkboxlist的使用
- ASP.NET MVC4.0中自定义CheckBoxListHelper和RadioBoxListHelper的使用
- C++ MFC combo box和list control控件的使用
- MFC ListControl的使用
- VC List Control控件高级使用
- ASP.NET MVC 中使用“RadioButtonList”和“CheckBoxList”
- MFC学习之List Control的使用
- s:checkboxlist使用