当我在Checkedlistbox中检查下面的其他Checbox时,如何检查Checkedlistbox中的所有项目? [英] How To Checked All Items In Checkedlistbox When I Check Other Checbox Below In The Checkedlistbox?

查看:86
本文介绍了当我在Checkedlistbox中检查下面的其他Checbox时,如何检查Checkedlistbox中的所有项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我检查CheckedListBox中的其他checbox时,如何检查CheckedListBox中的所有项目?

how to checked all items in CheckedListBox when i check other checbox take below in the CheckedListBox?

推荐答案

这是for winform:

This is for winform:
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
    for (int i = 0; i < checkedListBox1.Items.Count; i++)
    {
        checkedListBox1.SetItemChecked(i, checkBox1.Checked);
    }
}


参考此链接:



选中使用jQuery取消选中ASPNet CheckBoxList中的所有项目 < br $>


或以下代码段:



Refer this link :

Check Uncheck all items in ASPNet CheckBoxList using jQuery

or below code snippet :

protected void cbExtList_OnSelectedIndexChanged(object sender, EventArgs e)
{
    try
    {
        if (Convert.ToInt32(this.cbExtList.SelectedItem.Value) == 0)
        {
            foreach (ListItem li in cbExtList.Items)
            {
                li.Selected = true;
            }
        }
        else
        {
            foreach (ListItem li in cbExtList.Items)
            {
                li.Selected = false;
            }
        }
    }
    catch (Exception ex)
    {
        Monitoring.WriteException(ex);
    }
}


这篇关于当我在Checkedlistbox中检查下面的其他Checbox时,如何检查Checkedlistbox中的所有项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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