using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1_checkedlestbox
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
foreach (object o in checkedListBox1.CheckedItems)
{
checkedListBox2.Items.Add(o);
}
for (int i = 0; i < checkedListBox1.Items.Count;i++ )
{
if (checkedListBox1.CheckedItems.Contains(checkedListBox1.Items[i]))
{
checkedListBox3.Items.Add(checkedListBox1.Items[i].ToString() + "被移动到了右边");
checkedListBox1.Items.Remove(checkedListBox1.Items[i]);
}
}
}
private void Exit_Click(object sender, EventArgs e)
{
this.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
checkedListBox1.Items.Add("星期一");
checkedListBox1.Items.Add("星期二");
checkedListBox1.Items.Add("星期三");
checkedListBox1.Items.Add("星期四");
checkedListBox1.Items.Add("星期五");
checkedListBox1.Items.Add("星期六");
checkedListBox1.Items.Add("星期日");
}
private void button2_Click(object sender, EventArgs e)
{
foreach(object o in checkedListBox1.Items)
{
checkedListBox2.Items.Add(o);
}
checkedListBox1.Items.Clear();
checkedListBox3.Items.Add("全部被移动到了右边");
}
private void button3_Click(object sender, EventArgs e)
{
foreach (object o in checkedListBox2.Items)
{
checkedListBox1.Items.Add(o);
}
checkedListBox2.Items.Clear();
checkedListBox3.Items.Add("全去左边了");
}
private void button4_Click(object sender, EventArgs e)
{
foreach (object o in checkedListBox2.CheckedItems)
{
checkedListBox1.Items.Add(o);
}
for (int i = 0; i<checkedListBox2.Items.Count; i++)
{
if (checkedListBox2.CheckedItems.Contains(checkedListBox2.Items[i]))
{
checkedListBox2.Items.Remove(checkedListBox2.Items[i]);
checkedListBox3.Items.Add(checkedListBox2.Items[i].ToString() + "被移动到了左边");
}
}
}
}
}