文本控件
1)ListBox列表框控件
在设计页面设计好,拖2个ListBox。1个label(显示你所选择的日期), 4个button(全往右,全往左,几个往右,几个往左,总共4个功能)
注意调整ListBox控件行为True
代码如下:
using System.Collections;
namespace WebApplication1
{
//listbox列表控件
public partial class _default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)//是否回传
{
ArrayList arrrayl = new ArrayList(); //实例化数组集合
arrrayl.Add("星期日"); //向集合中添加数据
arrrayl.Add("星期一");
arrrayl.Add("星期二");
arrrayl.Add("星期三");
arrrayl.Add("星期四");
arrrayl.Add("星期五");
arrrayl.Add("星期六");
ListBox1.DataSource = arrrayl; //数据来源绑定到Listbox控件中
ListBox1.DataBind();//执行绑定操作
}
}
protected void Button1_Click(object sender, EventArgs e)
{
//ListBox1每一项的数据传输到ListBox2
int count = ListBox1.Items.Count;
//用循环遍历
for (int i = 0; i < count; i++)
{
//count的值就是ListBox1数据的个数,如上为7
ListItem item = ListBox1.Items[0];
ListBox1.Items.Remove(item); //把ListBox1的数据取出到ListBox2,并删除ListBox1的取出数据
ListBox2.Items.Add(item);
}
}
protected void Button2_Click(object sender, EventArgs e)
{
//ListBox2每一项的数据传输到ListBox2
int count = ListBox2.Items.Count;
//用循环遍历
for (int i = 0; i < count; i+