C# 如何在文本框中获取检查表中的项目数?
我不想在检查表框的文本框中添加任何项目。但文本框中没有显示任何内容C# 如何在文本框中获取检查表中的项目数?,c#,checklistbox,C#,Checklistbox,我不想在检查表框的文本框中添加任何项目。但文本框中没有显示任何内容 private void button1_Click(object sender, EventArgs e) { for (int i = 0; i < chklst_scrips.Items.Count; i++) { if (chklst_scrips.GetItemCheckState(i) == CheckState.Checked)
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < chklst_scrips.Items.Count; i++)
{
if (chklst_scrips.GetItemCheckState(i) == CheckState.Checked)
{
for (int j = 0; ;j++ )
{
textBox1.Text = Convert.ToString(j);
}
}
}
}
private void按钮1\u单击(对象发送者,事件参数e)
{
对于(int i=0;i
只需创建一个计数器,并将其初始值设置为0
int counter = 0;
然后,每次选中复选框时,递增计数器,如下图所示,例如,如果您有一个名为checkBox1的复选框:
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
counter++
//Your code here
}
您需要在所有复选框中增加计数器
如果您使用的是checkedListBox,例如checkedListBox1,则只需使用
checkedListBox1.CheckedItems.Count
即可获得选中项目的数量。GetItemChecked方法将有助于从复选框列表中查找选中项目
for (int i = 0; i < checkedListBox1.Items.Count; i++)
{
if (checkedListBox1.GetItemChecked(i))
{
string str = (string)checkedListBox1.Items[i];
textBox1.Text += str;
}
}
for(int i=0;i
您的柜台在哪里?这将增加+++,条件错误!:/ListItemSystem.Web.UI.WebControl的库是什么?我没有得到该库…在windows窗体应用程序中工作如果我们想在listview的第2列HI supa中添加选择检查表框项,请提供支持。提问时请提供清楚的信息,以便有助于清楚回答。请联系我arjunan。developer@gmail.com