我在ItemCheck事件中是这么写得
private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
{
CheckedListBox clb = (CheckedListBox)sender;
for (int x = 0; x != checkedListBox1.CheckedItems.Count ; x++)
{
if (x != 0)
{
clb.Tag = true;
}
else
{
clb.Tag = false;
}
}
ValidateOK();
但是经过试验,必须选中三个以上的项目才能验证,到底是怎么回事呀
private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
{
CheckedListBox clb = (CheckedListBox)sender;
for (int x = 0; x != checkedListBox1.CheckedItems.Count ; x++)
{
if (x != 0)
{
clb.Tag = true;
}
else
{
clb.Tag = false;
}
}
ValidateOK();
但是经过试验,必须选中三个以上的项目才能验证,到底是怎么回事呀
解决方案 »
- 强制转化
- 通过按钮实现gridview的局部刷新
- pda 智能设备程序 窗体的事件没有FormClosing,只有closing,但是后者没有反应
- 请问大家类似于这种超级链接的弹出对话框是怎么实现的?
- 报表问题 我打开报表打印太慢~!!
- SetWindowLong在语言中的的差异
- C#中可以这样加载窗体吗?
- 在Win2008和win XP上使用VS 2008开发的两个同一版本系统,出现的错误提示!
- C# serialport 接收多个通道数据分别显示表格里
- 一个挑战:给Button类型数组赋数据表中的string类型值
- C# 标准表达式中数据类型不匹配。
- GDI+自定义控件开发视频讲座第一讲(散分啊)
{
if(e.NewValue==CheckState.Checked)
{}
}string s=String.Empty;
for (i = 0; i <=checkedListBox1.Items.Count-1; i++)
{
if(checkedListBox1.GetItemChecked(i))
{
s = checkedListBox1.Items[i].Value+",";
}
}
foreach(object item in checkedListBox1.Items) {
}
for (int i = 0; i < checkedListBox1.Items.Count; i++)
{
if (checkedListBox1.GetItemChecked(i))
{
BaseParser cli = null;
switch (checkedListBox1.GetItemText(checkedListBox1.Items[i]))
{
case "ssw":
cli = new Soso();
bplist.Add(cli);
break;
case "ww":
cli = new Wenwen();
bplist.Add(cli);
break;
case "ss":
cli = new SosoBlog();
bplist.Add(cli);
break;
case "sa":
cli = new Sogou();
bplist.Add(cli);
break;
case "a":
cli = new _1688();
bplist.Add(cli);
break;
case "q":
cli = new Xywy();
bplist.Add(cli);
break;
default:
break;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent(); //add 3 items to collection checkedListBox
//and make sure one item is chosen,
checkedListBox1.Items.Add("KDS",true);
checkedListBox1.Items.Add("2");
checkedListBox1.Items.Add("3"); //listChecked就是处于选中状态的所有item集合
CheckedListBox.CheckedItemCollection listChecked = checkedListBox1.CheckedItems;
for (int i = 0; i < listChecked.Count; i++)
{
//将被选中item的text打印出来
MessageBox.Show("{0}", listChecked[0].ToString()); }
}
}}