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 在包含多个列的列表框中,这个属性指定列宽 ...
随机推荐
- hdoj-2090-算菜价(水题)
算菜价 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...
- windows 目录空格
Window下安装Scala出现:此时不应有 \scala\bin\..\lib\jline-2.14.5.jar 原因很简单,scala默认安装到了Program Files (x86)文件夹下,目 ...
- js加减乘除丢失精度
js加减乘除(学了那么久现在才注意到汗==!) /** ** 除法函数,用来得到精确的除法结果 ** 说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显.这个函数返回较为精 ...
- HDU1054 Strategic Game —— 最小点覆盖 or 树形DP
题目链接:https://vjudge.net/problem/HDU-1054 Strategic Game Time Limit: 20000/10000 MS (Java/Others) ...
- YTU 2562: 黄金螺旋
2562: 黄金螺旋 时间限制: 1 Sec 内存限制: 128 MB 提交: 832 解决: 427 题目描述 黄金螺旋是根据斐波那契数列画出来的螺旋曲线,自然界中存在许多斐波那契螺旋线的图案, ...
- codeforces 686C C. Robbers' watch(dfs)
题目链接: C. Robbers' watch time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- BZOJ_3476_[Usaco2014 Mar]The Lazy Cow_扫描线+切比雪夫距离
BZOJ_3476_[Usaco2014 Mar]The Lazy Cow_扫描线+切比雪夫距离 Description It's a hot summer day, and Bessie the c ...
- less 语法
1 变量 less的变量使用@开头 1.1 demo @colorRed:red; @colorBlue:blue; .demo{ color:@colorRed; background-color: ...
- linq to EF分组查询 group by 的使用
第一种:查询表达式语法: IQueryable<EnrollmentDateGroup> data = from student in db.Students group student ...
- express中cookie的使用和cookie-parser的解读
https://segmentfault.com/a/1190000004139342?_ea=504710 最近在研究express,学着使用cookie,开始不会用,就百度了一下,没有百度到特别完 ...