<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. 书评第003篇:《0day安全:软件漏洞分析技术(第2版)》

    本书基本信息 丛书名:安全技术大系 作者:王清(主编),张东辉.周浩.王继刚.赵双(编著) 出版社:电子工业出版社 出版时间:2011-6-1 ISBN:9787121133961 版次:1 页数:7 ...

  2. 我的Android进阶之旅------&gt;Android编译错误java.util.zip.ZipException: duplicate entry的解决方法

    今天在Android Studio中把另外一个项目引入当前项目,编译的时候出现了java.util.zip.ZipException: duplicate entry错误. 错误例如以下所看到的: F ...

  3. Android之——经常使用手机号码功能

    转载请注明出处:http://blog.csdn.net/l1028386804/article/details/47374415 有些Android手机中会带有一些经常使用号码的功能,比方订餐电话. ...

  4. BZOJ 2243: [SDOI2011]染色 树链剖分+线段树区间合并

    2243: [SDOI2011]染色 Description 给定一棵有n个节点的无根树和m个操作,操作有2类: 1.将节点a到节点b路径上所有点都染成颜色c: 2.询问节点a到节点b路径上的颜色段数 ...

  5. Linux 下的编辑/编译器

    linux 首先有两个重量级的文本编辑器:vim 和 emacs 此外有如下三种比较好的开放环境: 1.Anjuta Anjuta DevStudio 的官方地址:http://anjuta.sour ...

  6. cocos2dx笔记1:概述

    1.核心的类和功能 CCDirector gameLoop,实现场景绘制.多个场景之间切换控制.控制游戏的停止,暂停,等生命周期. CCScene 场景类,每一个场景能够理解为一个游戏镜头.状态 CC ...

  7. hosts所在文件夹以及***

    hosts所在文件夹: Windows 系统hosts位于 C:\Windows\System32\drivers\etc\hosts Android(安卓)系统hosts位于 /etc/hosts ...

  8. Eclipse添加Qt插件

    此文件仅为步骤操作作一个记录,以便以后方便查阅. 1.操作大体参考这个网站:http://blog.csdn.net/defonds/article/details/5013412 2.我的运行环境: ...

  9. c# 字节高低位

    byte n = br.ReadByte(); ; // 高位 var l = n & 0x0f; // 低位

  10. 关于mysqld_safe

    昨天花了一天时间写了mysql的源码安装,比较蛋疼.其中对于mysqld_safe尤其不理解,因为使用apt-get安装几乎中间不需要什么配置,只需要service mysql start即可,但是源 ...