Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1850338
  • 博文数量: 699
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 4970
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-15 13:45
文章分类

全部博文(699)

文章存档

2011年(1)

2008年(698)

我的朋友

分类:

2008-10-15 13:46:24

        在ASP1.1中如果要实现两个ListBox相互传递数据,比如有两个ListBox ListBox1 和 ListBox2

Width="100px">
 单片机
 网络程序设计
 电子商务
 计算机图形学
 分布式系统
 JSP技术

Width="100px">

添加两个Button button1 和 button2


给button1添加Click事件

private void Button1_Click(object sender, System.EventArgs e)
{
 this.ListBox2.Items.Add(this.ListBox1.SelectedItem);
 this.ListBox1.Items.Remove(this.ListBox1.SelectedItem);
}

button2的Click事件
private void Button2_Click(object sender, System.EventArgs e)
{
 this.ListBox1.Items.Add(this.ListBox2.SelectedItem);
 this.ListBox2.Items.Remove(this.ListBox2.SelectedItem);
}
假象 :表面上看基本的功能已经实现了,编译运行,点击"添加"按钮ListBox1中选中的确实跑到ListBox2中了,再次点击 出现错误“当SelectionMode 为 Single 时,ListBox 不能有多个选定项。”

改正方法1:修改ListBox1 和 ListBox2的SelectionMode 属性 设置为 Multiple ,基本上可以实现,但是效果很次。

[1]  

【责编:Luzi】

--------------------next---------------------

阅读(343) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~