listBox 搜索左右移动
<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 搜索左右移动的更多相关文章
- WPF 自定义列表筛选 自定义TreeView模板 自定义ListBox模板
有很多项目,都有数据筛选的操作.下面提供一个案例,给大家做参考. 左侧是数据源,搜索框加TreeView控件,右侧是ListBox控件.在左侧数据列点击添加数据,然后点击确定,得到所筛选的数据. 下面 ...
- MFC编程入门之二十四(常用控件:列表框控件ListBox)
前面两节讲了比较常用的按钮控件,并通过按钮控件实例说明了具体用法.本文要讲的是列表框控件(ListBox)及其使用实例. 列表框控件简介 列表框给出了一个选项清单,允许用户从中进行单项或多项选择,被选 ...
- 图片轮播(bootstrap)与 圆角搜索框(纯css)
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...
- 【WP8.1开发】选择与搜索联系人
在需要的情况下,可以通过相关的API来访问手机上的联系人信息:当然,在不必要的情况下,不要随便去获取别人的数据. 要从联系人列表中选择并获取一位或者N位联系人的详细信息,比较简单的做法是利用Conta ...
- Lucene.net站内搜索—2、Lucene.Net简介和分词
目录 Lucene.net站内搜索—1.SEO优化 Lucene.net站内搜索—2.Lucene.Net简介和分词Lucene.net站内搜索—3.最简单搜索引擎代码Lucene.net站内搜索—4 ...
- GUI开发者桌面搜索文件工具
# - *- coding:utf-8-*-from Tkinter import *import tkMessageBoximport tkFileDialogimport osimport fnm ...
- [SAP ABAP开发技术总结]搜索帮助Search Help (F4)
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- Html.Listbox的用法(实例)
homecontroller控制器中的index动作代码如下: public actionresult index() { list<selectlistitem& ...
- C# Windows - ListBox&CheckedListBox
ListBox和CheckedListBox类的属性 属性 说明 SelectedIndex 这个值表明列表框中选中项的基于0的索引 ColumnWidth 在包含多个列的列表框中,这个属性指定列宽 ...
随机推荐
- anaconda中新rdkit安装
1. 执行 conda create -c rdkit -n my-rdkit-env rdkit 该步骤经测试发现需FQ,而模拟器无法完成FQ(至少我不知道方法), 因此在本机上配置好环境后复制粘贴 ...
- Num 36 : ZOJ 2100 [ 深度优先搜索算法 ] [ 回溯 ]
该题是用回溯法来解决的题: 题目: Seeding Time Limit: 2 Seconds Memory Limit: 65536 KB It is spring time and fa ...
- 识别IE11浏览器
现在俺们做的系统十分高大上,用IE的话非要上IE11或以上版本. 咋检测呢?检测到用户用IE.且IE低于IE11的话就提示他升级浏览器呢?可以酱紫: var _IE = (function (d, w ...
- 2016/05/11 Thinkphp 3.2.2 验证码 使用 及校验
先新建一个公共控制器,用于放置验证码的实例化代码(不用新建控制器也行,任意公共控制器都可以). 例如:PublicController.class.php 4 5 6 7 8 9 10 11 12 1 ...
- debian包之间的关系
1 debian包之间存在两大类关系 第一,依赖 第二,冲突 2 依赖类关系 2.1 depends 2.2 pre-depends 2.3 recommends 2.4 suggests 2.5 e ...
- forword 与 redirect
直接转发方式(Forward) 客户端和浏览器只发出一次请求,Servlet.HTML.JSP或其它信息资源,由第二个信息资源响应该请求,在请求对象request中,保存的对象对于每个信息资源是共享的 ...
- YTU 2811: 打鱼还是晒网
2811: 打鱼还是晒网 时间限制: 1 Sec 内存限制: 128 MB 提交: 192 解决: 150 题目描述 中国有句俗话"三天打鱼,两天晒网".小王从2000年的1月 ...
- 深入了解以太坊虚拟机第4部分——ABI编码外部方法调用的方式
在本系列的上一篇文章中我们看到了Solidity是如何在EVM存储器中表示复杂数据结构的.但是如果无法交互,数据就是没有意义的.智能合约就是数据和外界的中间体. 在这篇文章中我们将会看到Solidit ...
- JSONArray ja = JSONArray.fromObject(list);//特殊类 用于将list转化为JSON 数据并返回 out.print(ja);
JSONArray ja = JSONArray.fromObject(list);//特殊类 用于将list转化为JSON 数据并返回out.print(ja);
- 配置磁盘映射(在服务器和eclipse 中)
在eclipse中配置磁盘映射和项目名称访问省略: