C# ListBox数据互换
来源:互联网 发布:经典网络歌曲打包下载 编辑:程序博客网 时间:2024/05/29 18:15
C#中两个ListBox数据互换的逻辑,下面为一段实例code,供参考。
private void btn2Right_Click(object sender, System.EventArgs e)
{
//Add item from ListBox1
for (int i = 0; i < this.ListBox1.Items.Count ; i++)
{
if(ListBox1.Items[i].Selected)
{
this.ListBox2.Items.Add(new ListItem(ListBox1.Items[i].Text,ListBox1.Items[i].Value));
}
}
//Delete item from ListBox1, when it add item to ListBox2 successful
for (int i = this.ListBox1.Items.Count -1; i >=0 ; i--)
{
if(ListBox1.Items[i].Selected)
{
this.ListBox1.Items.Remove(ListBox1.Items[i]);
}
}
}
private void btn2Left_Click(object sender, System.EventArgs e)
{
//Add item from ListBox2
for (int i = 0; i < this.ListBox2.Items.Count ; i++)
{
if(ListBox2.Items[i].Selected)
{
this.ListBox1.Items.Add(new ListItem(ListBox2.Items[i].Text,ListBox2.Items[i].Value));
}
}
//Delete item from ListBox2, when it add item to ListBox1 successful
for (int i = this.ListBox2.Items.Count -1; i >=0 ; i--)
{
if(ListBox2.Items[i].Selected)
{
this.ListBox2.Items.Remove(ListBox2.Items[i]);
}
}
}
- C# ListBox数据互换
- 两个ListBox中的Item互换
- C#将ListBox数据导出到Excel中
- c# ListBox绑定对象时删除数据的问题
- c# listview ,listbox
- C# ListBox用法
- 实现C# listbox双击
- C# Listbox的使用
- C# listBox 设置
- C# ListBox显示tooltip
- c# listbox简析
- C#中的ListBox应用
- C# listbox 用法
- C# ListBox 控件
- 两个Select互换数据
- Excel 行列数据互换
- mysql互换表中两列数据
- ListBox的数据绑定
- 小型化定制
- 抓周清单
- 情感营销的秘诀:这样的服务真能感动消费者
- 在vb.net中关于datagridview的一些操作
- 学习Servlet小结
- C# ListBox数据互换
- 婚姻家庭
- 四大主流数据库比较
- Google排名优化-面向搜索引擎的网站设计
- 如何做好一个垂直搜索引擎
- Index
- nginx学习笔记
- 郭老师总结servlet
- [英语阅读]生而为赢—新东方英语背诵美文(3)-Companionship of Books 以书为伴(节选)