<td align="left" width="50%">
查询:<asp:TextBox ID="SacffSearch" runat="server" Width="54px"></asp:TextBox><asp:Button runat="server" Text="搜索" id="tbnSearch" OnClick="tbnSearch_Click"></asp:Button>
<asp:ListBox ID="AllPeople" runat="server" Height="100px" Width="148px" AutoPostBack="true" SelectionMode="Multiple" OnSelectedIndexChanged="AllPeople_SelectedIndexChanged"></asp:ListBox>
</td>

listbox左右移动带搜索功能

后台代码

  protected void PersonLMove_Click(object sender, EventArgs e)
{
IList<ListItem> list = new List<ListItem>();
var count = AllPeople.Items.Count;
for (int i = ; i < count; i++)
{
var onepeopleitem = AllPeople.Items[i];
if (onepeopleitem.Selected)
{
NeedExamStaff.Items.Add(onepeopleitem);
list.Add(onepeopleitem);
}
}
for (int i = ; i < list.Count(); i++)
{
AllPeople.Items.Remove(list[i]);
}
NeedStaffNumber.Text = NeedExamStaff.Items.Count.ToString(); } protected void PersonRMove_Click(object sender, EventArgs e)
{
IList<ListItem> list = new List<ListItem>();
var count = NeedExamStaff.Items.Count;
for (int i = ; i < NeedExamStaff.Items.Count; i++)
{
var onepeopleitem = NeedExamStaff.Items[i];
if (onepeopleitem.Selected)
{
AllPeople.Items.Add(onepeopleitem);
list.Add(onepeopleitem);
}
}
for (int i = ; i < list.Count(); i++)
{
NeedExamStaff.Items.Remove(list[i]);
} NeedStaffNumber.Text = NeedExamStaff.Items.Count.ToString();
} protected void PersonLAll_Click(object sender, EventArgs e)
{
IList<ListItem> list = new List<ListItem>();
var count = AllPeople.Items.Count;
for (int i = ; i < count; i++)
{
var onepeopleitem = AllPeople.Items[i];
NeedExamStaff.Items.Add(onepeopleitem);
list.Add(onepeopleitem); }
for (int i = ; i < list.Count(); i++)
{
AllPeople.Items.Remove(list[i]);
}
NeedStaffNumber.Text = NeedExamStaff.Items.Count.ToString();
} protected void PersonRAll_Click(object sender, EventArgs e)
{
IList<ListItem> list = new List<ListItem>();
var count = NeedExamStaff.Items.Count;
for (int i = ; i < NeedExamStaff.Items.Count; i++)
{
var onepeopleitem = NeedExamStaff.Items[i];
AllPeople.Items.Add(onepeopleitem);
list.Add(onepeopleitem);
}
for (int i = ; i < list.Count(); i++)
{
NeedExamStaff.Items.Remove(list[i]);
} NeedStaffNumber.Text = NeedExamStaff.Items.Count.ToString();
}
   protected void tbnSearch_Click(object sender, EventArgs e)
{
var searchContnet = this.SacffSearch.Text.TrimEnd(',').Split(',');
var count = AllPeople.Items.Count; for (int k = ; k < searchContnet.Length; k++)
{
var j = ;
for (int i = ; i < count; i++)
{
if (AllPeople.Items[i].Text.Trim() == searchContnet[k].Trim())
{
AllPeople.Items[i].Selected = true;
AllPeople.SelectedIndex = i;
break;
}
}
if (AllPeople.SelectedIndex > )
{
int idx = AllPeople.SelectedIndex;
var SelectedItem = AllPeople.SelectedItem;
AllPeople.Items.Insert(, new ListItem(SelectedItem.Text, SelectedItem.Value));
AllPeople.Items.RemoveAt(AllPeople.SelectedIndex);
AllPeople.SelectedIndex = ;
}
} }

listBox 搜索左右移动的更多相关文章

  1. WPF 自定义列表筛选 自定义TreeView模板 自定义ListBox模板

    有很多项目,都有数据筛选的操作.下面提供一个案例,给大家做参考. 左侧是数据源,搜索框加TreeView控件,右侧是ListBox控件.在左侧数据列点击添加数据,然后点击确定,得到所筛选的数据. 下面 ...

  2. MFC编程入门之二十四(常用控件:列表框控件ListBox)

    前面两节讲了比较常用的按钮控件,并通过按钮控件实例说明了具体用法.本文要讲的是列表框控件(ListBox)及其使用实例. 列表框控件简介 列表框给出了一个选项清单,允许用户从中进行单项或多项选择,被选 ...

  3. 图片轮播(bootstrap)与 圆角搜索框(纯css)

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...

  4. 【WP8.1开发】选择与搜索联系人

    在需要的情况下,可以通过相关的API来访问手机上的联系人信息:当然,在不必要的情况下,不要随便去获取别人的数据. 要从联系人列表中选择并获取一位或者N位联系人的详细信息,比较简单的做法是利用Conta ...

  5. Lucene.net站内搜索—2、Lucene.Net简介和分词

    目录 Lucene.net站内搜索—1.SEO优化 Lucene.net站内搜索—2.Lucene.Net简介和分词Lucene.net站内搜索—3.最简单搜索引擎代码Lucene.net站内搜索—4 ...

  6. GUI开发者桌面搜索文件工具

    # - *- coding:utf-8-*-from Tkinter import *import tkMessageBoximport tkFileDialogimport osimport fnm ...

  7. [SAP ABAP开发技术总结]搜索帮助Search Help (F4)

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  8. Html.Listbox的用法(实例)

    homecontroller控制器中的index动作代码如下:         public actionresult index()        { list<selectlistitem& ...

  9. C# Windows - ListBox&CheckedListBox

    ListBox和CheckedListBox类的属性 属性 说明 SelectedIndex 这个值表明列表框中选中项的基于0的索引 ColumnWidth 在包含多个列的列表框中,这个属性指定列宽 ...

随机推荐

  1. 【转载】How browsers work--Behind the scenes of modern web browsers (前端必读)

    浏览器可以被认为是使用最广泛的软件,本文将介绍浏览器的工 作原理,我们将看到,从你在地址栏输入google.com到你看到google主页过程中都发生了什么. 将讨论的浏览器 今天,有五种主流浏览器- ...

  2. SDUT 3503 有两个正整数,求N!的K进制的位数

    有两个正整数,求N!的K进制的位数 题目链接:action=showproblem&problemid=3503">http://sdutacm.org/sdutoj/prob ...

  3. Linux IO 多路复用是什么意思?

    写在前面:本文整理于知乎,原文链接为http://www.zhihu.com/question/32163005/answer/55772739,作者:罗志宇 再次向作者表示感谢~~ 假设你是一个机场 ...

  4. cocos2d-x中锚点设置及定位方式

    问题 在cocos2d演示样例代码HelloCpp中,为什么要将CCMenu设置位置到CCPointZero,即使CCMenu的锚点是在(0.5, 0.5)? 回答 这是由于CCMenu没有使用锚点进 ...

  5. STL_算法_元素计数(count、count_if)

    C++ Primer 学习中.. . 简单记录下我的学习过程 (代码为主) count . count_if #include<iostream> #include<cstdio&g ...

  6. Python代码分析工具

    Python代码分析工具:PyChecker.Pylint - CSDN博客 https://blog.csdn.net/permike/article/details/51026156

  7. socket.io实现在线群聊

    我自己在用socket.io开发,对官方网站上的文档,进行简单的整理,然后自己写了一个简单的聊天程序.最最开始 先安装socket.io: npm install socket.io 利用Node的搭 ...

  8. camera闪光灯校准

    1. adb shell 2. setprop z.flash_ratio 1 3. 全黑环境下,请将手机固定,对着白墙10cm,固定. 4. 点击拍照,然后手机会自动打闪2(Duty num)次(其 ...

  9. Recovery启动流程(1)--- 应用层到开机进入recovery详解

    转载请注明来源:cuixiaolei的技术博客 进入recovery有两种方式,一种是通过组合键进入recovery,另一种是上层应用设置中执行安装/重置/清除缓存等操作进行recovery.这篇文档 ...

  10. 并不对劲的p3709:大爷的字符串题

    题目大意 区间众数 题解 莫队 代码 #include<algorithm> #include<cmath> #include<cstdio> #include&l ...