会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
DODONG
博客园
首页
新随笔
联系
订阅
管理
公告
多选列表框
<
asp:ListBox id
=
"
ListBox1
"
style
=
"
Z-INDEX: 100; LEFT: 256px; POSITION: absolute; TOP: 120px
"
runat
=
"
server
"
SelectionMode
=
"
Multiple
"
Width
=
"
73px
"
Height
=
"
134px
"
>
<
asp:ListItem Value
=
"
1
"
>
1
</
asp:ListItem
>
<
asp:ListItem Value
=
"
2
"
>
2
</
asp:ListItem
>
<
asp:ListItem Value
=
"
3
"
>
3
</
asp:ListItem
>
<
asp:ListItem Value
=
"
4
"
>
4
</
asp:ListItem
>
<
asp:ListItem Value
=
"
5
"
>
5
</
asp:ListItem
>
<
asp:ListItem Value
=
"
6
"
>
6
</
asp:ListItem
>
</
asp:ListBox
>
<
asp:Label id
=
"
Label2
"
style
=
"
Z-INDEX: 107; LEFT: 448px; POSITION: absolute; TOP: 96px
"
runat
=
"
server
"
>
列表框2
</
asp:Label
>
<
asp:ListBox id
=
"
ListBox2
"
style
=
"
Z-INDEX: 101; LEFT: 440px; POSITION: absolute; TOP: 120px
"
runat
=
"
server
"
SelectionMode
=
"
Multiple
"
Width
=
"
72px
"
Height
=
"
134px
"
></
asp:ListBox
>
<
asp:Button id
=
"
Upbtn
"
style
=
"
Z-INDEX: 102; LEFT: 360px; POSITION: absolute; TOP: 136px
"
runat
=
"
server
"
Text
=
"
上移
"
></
asp:Button
>
<
asp:Button id
=
"
Movebtn
"
style
=
"
Z-INDEX: 103; LEFT: 360px; POSITION: absolute; TOP: 176px
"
runat
=
"
server
"
Text
=
"
转移
"
></
asp:Button
>
<
asp:Button id
=
"
Downbtn
"
style
=
"
Z-INDEX: 104; LEFT: 360px; POSITION: absolute; TOP: 216px
"
runat
=
"
server
"
Text
=
"
下移
"
></
asp:Button
>
<
asp:Label id
=
"
Label1
"
style
=
"
Z-INDEX: 106; LEFT: 264px; POSITION: absolute; TOP: 96px
"
runat
=
"
server
"
>
列表框1
</
asp:Label
>
private
void
Movebtn_Click(
object
sender, System.EventArgs e)
{
int
Count
=
ListBox1.Items.Count;
int
Index
=
0
;
for
(
int
i
=
0
;i
<
Count;i
++
)
{
ListItem Item
=
ListBox1.Items[Index];
if
(ListBox1.Items[Index].Selected
==
true
)
{
ListBox1.Items.Remove(Item);
ListBox2.Items.Add(Item);
Index
--
;
}
Index
++
;
}
}
private
void
Upbtn_Click(
object
sender, System.EventArgs e)
{
//
若不是第一行则上移
if
( ListBox1.SelectedIndex
>
0
)
{
string
name
=
ListBox1.SelectedItem.Text;
string
ID
=
ListBox1.SelectedItem.Value;
int
index
=
ListBox1.SelectedIndex;
ListBox1.SelectedItem.Text
=
ListBox1.Items[index
-
1
].Text;
ListBox1.SelectedItem.Value
=
ListBox1.Items[index
-
1
].Value;
ListBox1.Items[index
-
1
].Text
=
name;
ListBox1.Items[index
-
1
].Value
=
ID;
ListBox1.SelectedIndex
--
;
}
}
private
void
Downbtn_Click(
object
sender, System.EventArgs e)
{
//
若不是最后一行则下移
if
( ListBox1.SelectedIndex
>=
0
&&
ListBox1.SelectedIndex
<
ListBox1.Items.Count
-
1
)
{
string
name
=
ListBox1.SelectedItem.Text;
string
ID
=
ListBox1.SelectedItem.Value;
int
index
=
ListBox1.SelectedIndex;
ListBox1.SelectedItem.Text
=
ListBox1.Items[index
+
1
].Text;
ListBox1.SelectedItem.Value
=
ListBox1.Items[index
+
1
].Value;
ListBox1.Items[index
+
1
].Text
=
name;
ListBox1.Items[index
+
1
].Value
=
ID;
ListBox1.SelectedIndex
++
;
}
posted on
2005-10-11 22:40
DODONG
阅读(
903
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
Powered by:
博客园
Copyright © 2024 DODONG
Powered by .NET 8.0 on Kubernetes