110,534
社区成员
发帖
与我相关
我的任务
分享
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());
}
}
}
}
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;
}
}
}