标题:[求助]c#基础问题,请问为什么编辑出来的checkedListBox1为什么向2中移动3项 ...
只看楼主
sylzhc
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-5-21
 问题点数:0 回复次数:1 
[求助]c#基础问题,请问为什么编辑出来的checkedListBox1为什么向2中移动3项以上就

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() + "被移动到了左边");
}
}
}
}
}

搜索更多相关主题的帖子: using System 基础 public 
2007-05-21 22:39
flyboatzgc
Rank: 1
等 级:新手上路
帖 子:55
专家分:0
注 册:2006-9-25
得分:0 
问题能说详细点吗?
2007-05-22 01:22



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-141330-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.379448 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved