前台两个listbox的控件代码如下:
ListBox1
ListBox2
border-color: #7F9DB9 #7F9DB9 #7F9DB9; border-right: 1px solid #7F9DB9; border-style: solid;
border-width: 1px; box-shadow: 0 1px 1px #FFFFFF; display: block; float: left;
vertical-align: top; position: relative; top: 110px; left: 15px; padding: 0;
margin: 0;" />
后台cs方法如下:
//清楚全部
protected void btnClear_Click(object sender, EventArgs e)
{
int count = listSend.Items.Count;
int index = 0;
for (int i = 0; i < count; i++)
{
ListItem item = listSend.Items[index];
listSend.Items.Remove(item);
}
index++;
}
//右移
protected void btnAddRight_Click(object sender, EventArgs e)
{
if (listYuan.SelectedIndex <= -1)
{
Common.ShowAlter(this.Page, "提示", "请选择要要右移的数据");
return;
}
int count = listYuan.Items.Count;
int index = 0;
for (int i = 0; i < count; i++)
{
ListItem item = listYuan.Items[index];
if (item.Selected == true)
{
listYuan.Items.Remove(item);
listSend.Items.Add(item);
this.listSend.SelectedIndex = (listSend.Items.Count - 1);
index--;
}
index++;
}
}
//左移
protected void btnAddLeft_Click(object sender, EventArgs e)
{
int count = listSend.Items.Count;
int index = 0;
for (int i = 0; i < count; i++)
{
ListItem item = listSend.Items[index];
if (item.Selected == true)
{
listSend.Items.Remove(item);
listYuan.Items.Add(item);
this.listYuan.SelectedIndex = (this.listYuan.Items.Count - 1);
index--;
}
index++;
}
}