欢迎来到天天文库
浏览记录
ID:50351385
大小:639.00 KB
页数:21页
时间:2020-03-08
《ASP NET程序设计(徐占鹏)教学资源单元3 控件的使用--5(案例).ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、案例主讲教师:宋园园案例ListBox控件应用案例:编写一个Web应用程序,要求利用两个通用列表控件ListBox实现动态的添加和删除选项的功能。案例分析该程序要求实现在两个ListBox控件之间实现选项的添加和删除,也就是说在左侧列表框中选定选项后,就可以将其移动到右侧的列表框中,同理在右侧列表框中选定选项后,也可以将其移动到左侧的列表框中。ListBox控件应用案例运行结果ListBox控件应用案例编辑btnAlltoRight_Click方法01protectedvoidbtnAlltoRight_Click(objectsender,EventArgse){02:in
2、ti;ListItemobjItem;04:for(i=0;i3、,EventArgse){02:if(this.ListBox1.SelectedIndex!=-1){03:ListItemobjItem;04:objItem=newListItem(ListBox1.SelectedItem.Text,.ListBox1.SelectedItem.Value);05:this.ListBox2.Items.Add(objItem);this.ListBox1.Items.Remove(this.ListBox1.SelectedItem);}06:btnState();}ListBox控件应用案例编辑btnAlltoLeft_Click4、方法01:protectedvoidbtnAlltoLeft_Click(objectsender,EventArgse){02:inti;03:ListItemobjItem;04:for(i=0;i5、toLeft_Click方法01:protectedvoidbtntoLeft_Click(objectsender,EventArgse){02:if(this.ListBox2.SelectedIndex!=-1){03:ListItemobjItem;04:objItem=newListItem(ListBox2.SelectedItem.Text,.ListBox2.SelectedItem.Value);05:this.ListBox1.Items.Add(objItem);this.ListBox2.Items.Remove(this.ListBox2.Selec6、tedItem);}06:btnState();}ListBox控件应用案例编辑btnState函数01:voidbtnState(){02:if(this.ListBox1.Items.Count==0){03:this.btnAlltoRight.Enabled=false;this.btntoRight.Enabled=false;05:this.btnAlltoLeft.Enabled=true;this.btntoLeft.Enabled=true;}07:elseif(this.ListBox2.Items.Count==0){08:this.btnAlltoLe7、ft.Enabled=false;this.btntoLeft.Enabled=false;09:this.btnAlltoRight.Enabled=true;this.btntoRight.Enabled=true;}10:else{11:this.btnAlltoRight.Enabled=true;this.btntoRight.Enabled=true;12:this.btnAlltoLeft.Enabled=true;this.btntoLeft.Enabled=true;13:}}复选与单
3、,EventArgse){02:if(this.ListBox1.SelectedIndex!=-1){03:ListItemobjItem;04:objItem=newListItem(ListBox1.SelectedItem.Text,.ListBox1.SelectedItem.Value);05:this.ListBox2.Items.Add(objItem);this.ListBox1.Items.Remove(this.ListBox1.SelectedItem);}06:btnState();}ListBox控件应用案例编辑btnAlltoLeft_Click
4、方法01:protectedvoidbtnAlltoLeft_Click(objectsender,EventArgse){02:inti;03:ListItemobjItem;04:for(i=0;i5、toLeft_Click方法01:protectedvoidbtntoLeft_Click(objectsender,EventArgse){02:if(this.ListBox2.SelectedIndex!=-1){03:ListItemobjItem;04:objItem=newListItem(ListBox2.SelectedItem.Text,.ListBox2.SelectedItem.Value);05:this.ListBox1.Items.Add(objItem);this.ListBox2.Items.Remove(this.ListBox2.Selec6、tedItem);}06:btnState();}ListBox控件应用案例编辑btnState函数01:voidbtnState(){02:if(this.ListBox1.Items.Count==0){03:this.btnAlltoRight.Enabled=false;this.btntoRight.Enabled=false;05:this.btnAlltoLeft.Enabled=true;this.btntoLeft.Enabled=true;}07:elseif(this.ListBox2.Items.Count==0){08:this.btnAlltoLe7、ft.Enabled=false;this.btntoLeft.Enabled=false;09:this.btnAlltoRight.Enabled=true;this.btntoRight.Enabled=true;}10:else{11:this.btnAlltoRight.Enabled=true;this.btntoRight.Enabled=true;12:this.btnAlltoLeft.Enabled=true;this.btntoLeft.Enabled=true;13:}}复选与单
5、toLeft_Click方法01:protectedvoidbtntoLeft_Click(objectsender,EventArgse){02:if(this.ListBox2.SelectedIndex!=-1){03:ListItemobjItem;04:objItem=newListItem(ListBox2.SelectedItem.Text,.ListBox2.SelectedItem.Value);05:this.ListBox1.Items.Add(objItem);this.ListBox2.Items.Remove(this.ListBox2.Selec
6、tedItem);}06:btnState();}ListBox控件应用案例编辑btnState函数01:voidbtnState(){02:if(this.ListBox1.Items.Count==0){03:this.btnAlltoRight.Enabled=false;this.btntoRight.Enabled=false;05:this.btnAlltoLeft.Enabled=true;this.btntoLeft.Enabled=true;}07:elseif(this.ListBox2.Items.Count==0){08:this.btnAlltoLe
7、ft.Enabled=false;this.btntoLeft.Enabled=false;09:this.btnAlltoRight.Enabled=true;this.btntoRight.Enabled=true;}10:else{11:this.btnAlltoRight.Enabled=true;this.btntoRight.Enabled=true;12:this.btnAlltoLeft.Enabled=true;this.btntoLeft.Enabled=true;13:}}复选与单
此文档下载收益归作者所有