如何计算在复选框列表中选中的复选框的数量 [英] how to count number of checkbox selected in checkedlistbox

查看:102
本文介绍了如何计算在复选框列表中选中的复选框的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要计算在清单列表框中选中了多少个复选框

i need to count how many checkbox got selected in the checkedlistbox

推荐答案

在这里您可以进行以下操作:

Here you go:

var count = checkedListBox1.SelectedItems.Count;


int icount = 0;
foreach (ListItem lItem in Listbox.Items)
{
 if (lItem.Selected == true)
 {
   icount++
 }
}


您可以像

you can do like

for (int i=0; i<checkboxlist1.Items.Count; i++)

         {



            if (checkboxlist1.Items[i].Selected)

            {



               Message.Text += checkboxlist1.Items[i].Text + "<br>";

            }

         }



有关更多详细信息,请访问msdn链接
http://msdn.microsoft. com/en-us/library/system.web.ui.webcontrols.checkboxlist%28v = vs.71%29.aspx [



For more detail follow msdn link
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.checkboxlist%28v=vs.71%29.aspx[^]


这篇关于如何计算在复选框列表中选中的复选框的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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