Listbox的一个用法
来源:互联网 发布:做陶瓷软件 编辑:程序博客网 时间:2024/05/16 15:29
功能:实现选中一个“LIstbox中的内容”,点击“Button”后把内容添加到另外的“Listbox”中
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ListBox ID="ListBox1" runat="server"></asp:ListBox>
<asp:ListBox ID="ListBox2" runat="server"></asp:ListBox>
<asp:Button ID="Button1" runat="server" Text="Button"
onclick="Button1_Click1" />
</div>
</form>
</body>
</html>
public partial class _Default : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
ArrayList al = new ArrayList();
al.Add("星期一");
al.Add("星期二");
al.Add("星期三");
this.ListBox1.DataSource = al;//指定数据源
this.ListBox1.DataBind();//执行绑定
}
}
protected void Button1_Click1(object sender, EventArgs e)
{
this.ListBox2.Items.Clear();
for (int i = 0; i < this.ListBox1.Items.Count; i++)
{
if (ListBox1.Items[i].Selected)
{
this.ListBox2.Items.Add(ListBox1.Items[i].Value);
}
}
for (int i = 0; i < this.ListBox1.Items.Count; i++)
{
if (this.ListBox1.Items[i].Selected)
{
this.ListBox1.Items.RemoveAt(i);
}
}
}
}
- Listbox的一个用法
- ListBox的用法
- listbox的用法
- 一个自定义的ListBox
- WPF的listbox的用法
- ListBox的一些基本用法
- WPF中的ListBox的用法
- ListBox用法
- ListBox 用法
- ListBox用法
- ListBox控件的基本用法(源代码)
- 树形控件,下拉框,listbox的用法
- 树形控件,下拉框,listbox的用法
- Asp.net中ListBox的用法!
- Asp.net中ListBox的用法!
- 【matlab GUI】GUI listbox的用法
- 一个非常Strong 的ListBox控件EasyList
- listbox用法摘要
- C语言中的逗号表达式与{}表达式用在宏返回值中
- VC调试器高级应用(高级断点篇)
- SIP服务器搭建——partysip
- 漫游动画摄像机制作
- IPC
- Listbox的一个用法
- WINCE物理和虚拟地址的问题
- 在实践中使用Jstat监控gc情况
- 在WindowsXP下用VS2005编译live555(2009.11.27)
- google map 图片 卫片 下载工具
- Xml读写
- 让iis支持asp.net
- IO反转输出
- 配置config.bib的注意事项以及错误分析——自己都要顶!