.NET支持上下左右移动操作
效果如下图:
代码如下:
public partial class ShowSet : System.Web.UI.Page
{
Hashtable resources = EquStatusSearch.resources;
private string names = null;
IniOperation ini = new IniOperation("i18n"); protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
names = QuarrysClass.All;
initi18n(); string[] all =string.IsNullOrEmpty(names)?null: names.Split(',');//分割出所有列
hidfShows.Value =ini.IniValue("Set", "Show");
string include = hidfShows.Value;//获取当前页展示列
if (string.IsNullOrEmpty(names)||all == null)
{
//请先点加载配置信息
return;
}
for (int i = 0; i < all.Length; i++)//遍历所有列
{
if (include.IndexOf("@" + all[i] + "@") == -1)//当前列中不包含分割出来的列时放在不显示框中
{
xListBox1.Items.Add(new ListItem(resources[all[i]].ToString(),all[i]));
}
}
string[] showNames = include.Split(',');
string newName=string.Empty;
foreach (string name in showNames)
{
newName = name.Trim('@');
string colName = resources[newName] == null ? string.Empty : resources[newName].ToString();
if (!string.IsNullOrEmpty(newName))
{
xListBox2.Items.Add(new ListItem(colName, newName));
}
}
}
} //调用显示和展示字段名称
private void initi18n()
{
this.Page.Title =string.IsNullOrEmpty(resources["ShowSetName"].ToString())? "字段显示设置" : resources["ShowSetName"].ToString();
xLabel1.Text =string.IsNullOrEmpty(resources["ShowSetNoShow"].ToString())?"不显示字段":resources["ShowSetNoShow"].ToString();
xLabel2.Text = string.IsNullOrEmpty(resources["ShowSetShow"].ToString())?"显示字段":resources["ShowSetShow"].ToString();
} //将未显示字段右移到显示字段框,并清除掉不显示的选择到的项
protected void xButton1_Click(object sender, EventArgs e)
{
if (xListBox1.SelectedItem == null)
{
return;
}
xListBox2.Items.Add(xListBox1.SelectedItem);
xListBox1.Items.Remove(xListBox1.SelectedItem);
} //将显示字段左移到未显示字段框,并清除掉显示的选择到的项
protected void xButton2_Click(object sender, EventArgs e)
{
if (xListBox2.SelectedItem == null)
{
return;
}
xListBox1.Items.Add(xListBox2.SelectedItem);
xListBox2.Items.Remove(xListBox2.SelectedItem);
} //将左边所有不显示项加到右边的显示项中
protected void xButton3_Click(object sender, EventArgs e)
{
foreach (ListItem item in xListBox1.Items)
{
xListBox2.Items.Add(item);
}
xListBox1.Items.Clear();
} //将右边所有不显示项加到左边的显示项中
protected void xButton4_Click(object sender, EventArgs e)
{
foreach (ListItem item in xListBox2.Items)
{
xListBox1.Items.Add(item);
}
xListBox2.Items.Clear();
} //点击设置按钮事件,
protected void btnSet_Click(object sender, EventArgs e)
{
try
{
string str = "";
for (int i = 0; i < xListBox2.Items.Count; i++)//循环添加显示项组成字符串
{
str += "@" + xListBox2.Items[i].Value + "@,";
}
if ("".Equals(str))//如果显示项为空直接清除显示页面的所有字段
{
QuarrysClass.Shows = "";
}
else
{
//重新复制显示字段到显示页面
QuarrysClass.Shows = str.Substring(0, str.Length - 1);
}
//调用主页面将显示字段写入到i18n文件中
ini.IniWriteValue("Set", "Show", QuarrysClass.Shows);
Page.ClientScript.RegisterStartupScript(this.GetType(), "warn", "alert('设置成功!');window.opener.searchData();window.close();", true); }
catch (Exception ex)
{
string strScript = string.Format("alert('设置失败!{0}');", ex.Message);
Page.ClientScript.RegisterStartupScript(this.GetType(), "warn", strScript, true);
}
} //上移
protected void btnUp_Click(object sender, EventArgs e)
{
UpMove(xListBox2);
} //下移
protected void btnDown_Click(object sender, EventArgs e)
{
DownMove(xListBox2);
} void UpMove(ListBox ListBox2)
{
//若不是第一行则上移
if (ListBox2.SelectedIndex > 0)
{
string name = ListBox2.SelectedItem.Text;
string ID = ListBox2.SelectedItem.Value;
int index = ListBox2.SelectedIndex;
ListBox2.SelectedItem.Text = ListBox2.Items[index - 1].Text;
ListBox2.SelectedItem.Value = ListBox2.Items[index - 1].Value;
ListBox2.Items[index - 1].Text = name;
ListBox2.Items[index - 1].Value = ID;
ListBox2.SelectedIndex--;
}
} void DownMove(ListBox lbox)
{
if (lbox.SelectedIndex < lbox.Items.Count - 1)
{
string name = lbox.SelectedItem.Text;
string ID = lbox.SelectedItem.Value;
int index = lbox.SelectedIndex;
lbox.SelectedItem.Text = lbox.Items[index + 1].Text;
lbox.SelectedItem.Value = lbox.Items[index + 1].Value;
lbox.Items[index + 1].Text = name;
lbox.Items[index + 1].Value = ID;
lbox.SelectedIndex++;
}
} void TopMove(ListBox lbox)
{
int index = 0;
ListItem item = lbox.SelectedItem;
lbox.Items.Remove(item);
lbox.Items.Insert(index, item);
} void BottomMove(ListBox lbox)
{
int index = lbox.Items.Count - 1;
ListItem item = lbox.SelectedItem;
lbox.Items.Remove(item);
lbox.Items.Insert(index, item);
} protected void btnTop_Click(object sender, EventArgs e)
{
TopMove(xListBox2);
} protected void btnBottom_Click(object sender, EventArgs e)
{
BottomMove(xListBox2);
} }
.NET支持上下左右移动操作的更多相关文章
- 开源 iOS 项目分类索引大全 - 待整理
开源 iOS 项目分类索引大全 GitHub 上大概600个开源 iOS 项目的分类和介绍,对于你挑选和使用开源项目应该有帮助 系统基础库 Category/Util sstoolkit 一套Cate ...
- 从ListView逐步演变到RecyclerView
ListView是我们开发中最常用的组件之一,在以往的PC端组件开发中,列表控件也是相当重要的,但是从桌面端到移动端,情况又有新的变化. 移动端的屏幕并不像桌面端那么大,并且移动端不可能把所有的内容都 ...
- 史上最全的常用iOS的第三方框架
文章来源:http://blog.csdn.net/sky_2016/article/details/45502921 图像: 1.图片浏览控件MWPhotoBrowser 实现了一个照片 ...
- 59.Android开源项目及库 (转)
转载 : https://github.com/Tim9Liu9/TimLiu-Android?hmsr=toutiao.io&utm_medium=toutiao.io&utm_so ...
- 常用iOS的第三方框架
图像:1.图片浏览控件MWPhotoBrowser 实现了一个照片浏览器类似 iOS 自带的相册应用,可显示来自手机的图片或者是网络图片,可自动从网络下载图片并进行缓存.可对图片进行缩放等 ...
- [Aaronyang]谈谈2015年AY对WPF全面技术总结40多篇WPF,炫到没朋友的AYUI来了
原著:AY WPF博客- 把wpf推广出去,让那些鄙视的人说不 大家好! 我是AY,首先声明,我在做一件很枯燥的事情,我是个91后程序员,每天熬夜完成计划的过着下班后的生活. 那天有 ...
- Android开源项目及库搜集
TimLiu-Android 自己总结的Android开源项目及库. github排名 https://github.com/trending,github搜索:https://github.com/ ...
- Unix/Linux环境C编程入门教程(21) 各个系统HelloWorld跑起来效果如何?
Unix/Linux家族人员众多,我们无法一一讲解如何配置环境. 本文选定我们在前面安装的RHEL6 RHEL7 MAC10.9.3 Solaris11如何跑起来helloworld RHEL 6 上 ...
- 开源 iOS 项目分类索引大全
GitHub 上大概600个开源 iOS 项目的分类和介绍,对于你挑选和使用开源项目应该有帮助 系统基础库 Category/Util sstoolkit 一套Category类型的库,附带很多自定义 ...
随机推荐
- 融合python2和python3
很多情况下你可能会想要开发一个程序能同时在python2和python3中运行. 想象一下你开发了一个模块,成百上千的人都在使用它,但不是所有的用户都同时使用python 2和3.这种情况下你有两个选 ...
- 第一个processing程序(2016-01-15)
前几天下载和安装了最新的 processing,今天试一下,哈哈,真是简单之极啊,果然是给非程序员使用的,现在,我也是非程序员了.
- BZOJ 1631: [Usaco2007 Feb]Cow Party( 最短路 )
这道题和蔡大神出的今年STOI初中组的第二题几乎一模一样... 先跑一遍最短路 , 再把所有边反向 , 再跑一遍 , 所有点两次相加的最大值即为answer --------------------- ...
- Android 常用开源代码整理
1.AndroidAnnotations一个强大的android开源注解框架, 基本上可以注入任何类型, 比一般的所谓的注入框架要快, 因为他是通过生成一个子类来实现的绑定.具体查看文档. 2.and ...
- poj 2992
http://poj.org/problem?id=2992 大意:求(n,k)的因子个数 解题思路:(n,k) = n!/(k!(n-k)!) 任意一个数都可以用其质因子来表示 eg: 26 = ...
- design pattern factory method #Reprinted#
引入人.工厂.和斧子的问题: (1),原始社会时,劳动社会基本没有分工,需要斧子的人(调用者)只好自己去磨一把斧子,每个人拥有自己的斧子,如果把大家的石斧改为铁斧,需要每个人都要学会磨铁斧的本领,工作 ...
- JS常用方法函数(1)
1.字符串长度截取 function cutstr(str, len) { var temp, icount = 0, patrn = /[^\x00-\xff]/, strre = "&q ...
- 转:STL使用入门( Using STL)
1 介绍 我最开始结束C++编程是从DOS下的Borland C++开始的.那时他们在最新版本3.1中就包含了一套模板库用来做collection.那真是个好东东.当我开始使用Visual C++ 2 ...
- [对话CTO]当当网熊长青:兴趣是成为优秀工程师的第一因素-CSDN.NET
Women Techmaker 北京站 [对话CTO]当当网熊长青:兴趣是成为优秀工程师的第一因素-CSDN.NET [对话CTO]当当网熊长青:兴趣是成为优秀工程师的第一因素 发表于2 ...
- ligh@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.3
ligh@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.3