【.NET支持上下左右移动操作】
来源:互联网 发布:中国象棋分析软件 编辑:程序博客网 时间:2024/06/11 08:06
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
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支持上下左右移动操作】
- .NET上下左右移动操作支持多选
- 上下左右移动
- 控制控件上下左右移动
- div+css 上下左右移动
- 移动端上下左右滑动
- 移动的上下左右滑动
- 点击上下左右按钮让背景上下左右移动
- IOS开发笔记-01按钮操作-13.上下左右移动 14.代码优化
- 上下左右 键控制人移动
- 上下左右 键控制人移动
- Android TV 焦点上下左右移动
- 上下左右移动选择的布局
- ASP.NET 移动控件设备模板支持
- Asp.net MVC添加移动支持
- Unity在ipad上触屏双指上下左右移动,单指上下左右旋转
- C#实现treeview节点上下左右自由移动
- 随滚动条移动的上下左右中层
- hdu 3440 House Man
- Oracle服务器端和客户端安装配置
- Android预定义样式
- 十个值得学习的好习惯
- c++ vector使用笔记
- 【.NET支持上下左右移动操作】
- 查找数组中最小的k值
- sql截取字段的固定长度
- JDK中的URLConnection参数详解
- UITabbar 去除选中后高亮显示
- 通过MediaStore获取Audio信息
- js 动态切换视频
- 重拾java-改项目
- UVa413 - Up and Down Sequences