多选列表框

None.gif < asp:ListBox id = " ListBox1 "  style = " Z-INDEX: 100; LEFT: 256px; POSITION: absolute; TOP: 120px "
None.gif                runat
= " server "  SelectionMode = " Multiple "  Width = " 73px "  Height = " 134px " >
None.gif                
< asp:ListItem Value = " 1 " > 1 </ asp:ListItem >
None.gif                
< asp:ListItem Value = " 2 " > 2 </ asp:ListItem >
None.gif                
< asp:ListItem Value = " 3 " > 3 </ asp:ListItem >
None.gif                
< asp:ListItem Value = " 4 " > 4 </ asp:ListItem >
None.gif                
< asp:ListItem Value = " 5 " > 5 </ asp:ListItem >
None.gif                
< asp:ListItem Value = " 6 " > 6 </ asp:ListItem >
None.gif            
</ asp:ListBox >
None.gif            
< asp:Label id = " Label2 "  style = " Z-INDEX: 107; LEFT: 448px; POSITION: absolute; TOP: 96px "  runat = " server " > 列表框2 </ asp:Label >
None.gif            
< asp:ListBox id = " ListBox2 "  style = " Z-INDEX: 101; LEFT: 440px; POSITION: absolute; TOP: 120px "
None.gif                runat
= " server "  SelectionMode = " Multiple "  Width = " 72px "  Height = " 134px " ></ asp:ListBox >
None.gif            
< asp:Button id = " Upbtn "  style = " Z-INDEX: 102; LEFT: 360px; POSITION: absolute; TOP: 136px "  runat = " server "
None.gif                Text
= " 上移 " ></ asp:Button >
None.gif            
< asp:Button id = " Movebtn "  style = " Z-INDEX: 103; LEFT: 360px; POSITION: absolute; TOP: 176px "  runat = " server "
None.gif                Text
= " 转移 " ></ asp:Button >
None.gif            
< asp:Button id = " Downbtn "  style = " Z-INDEX: 104; LEFT: 360px; POSITION: absolute; TOP: 216px "  runat = " server "
None.gif                Text
= " 下移 " ></ asp:Button >
None.gif            
< asp:Label id = " Label1 "  style = " Z-INDEX: 106; LEFT: 264px; POSITION: absolute; TOP: 96px "  runat = " server " > 列表框1 </ asp:Label >
None.gif
None.gif        
private   void  Movebtn_Click( object  sender, System.EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif            
int Count = ListBox1.Items.Count;
InBlock.gif            
int Index = 0;
InBlock.gif            
for (int i=0;i< Count;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                ListItem Item 
= ListBox1.Items[Index];
InBlock.gif                
if (ListBox1.Items[Index].Selected==true)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    ListBox1.Items.Remove(Item);
InBlock.gif                    ListBox2.Items.Add(Item);
InBlock.gif                    Index
--;
ExpandedSubBlockEnd.gif                }

InBlock.gif                Index
++;
ExpandedSubBlockEnd.gif            }

ExpandedBlockEnd.gif        }

None.gif
None.gif        
private   void  Upbtn_Click( object  sender, System.EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif            
//若不是第一行则上移
InBlock.gif
            if( ListBox1.SelectedIndex > 0 )
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
string name = ListBox1.SelectedItem.Text;
InBlock.gif                
string ID = ListBox1.SelectedItem.Value;
InBlock.gif
InBlock.gif                
int index = ListBox1.SelectedIndex;
InBlock.gif
InBlock.gif                ListBox1.SelectedItem.Text 
= ListBox1.Items[index-1].Text;
InBlock.gif                ListBox1.SelectedItem.Value 
= ListBox1.Items[index-1].Value;
InBlock.gif                ListBox1.Items[index
-1].Text = name;
InBlock.gif                ListBox1.Items[index
-1].Value = ID;
InBlock.gif                ListBox1.SelectedIndex 
--;
ExpandedSubBlockEnd.gif            }

ExpandedBlockEnd.gif        }

None.gif
None.gif        
private   void  Downbtn_Click( object  sender, System.EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif            
//若不是最后一行则下移
InBlock.gif
            if( ListBox1.SelectedIndex >= 0 && ListBox1.SelectedIndex < ListBox1.Items.Count-1 )
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
string name = ListBox1.SelectedItem.Text;
InBlock.gif                
string ID = ListBox1.SelectedItem.Value;
InBlock.gif                
int index = ListBox1.SelectedIndex;
InBlock.gif                ListBox1.SelectedItem.Text 
= ListBox1.Items[index+1].Text;
InBlock.gif                ListBox1.SelectedItem.Value 
= ListBox1.Items[index+1].Value;
InBlock.gif                ListBox1.Items[index
+1].Text = name;
InBlock.gif                ListBox1.Items[index
+1].Value = ID;
InBlock.gif                ListBox1.SelectedIndex 
++;
ExpandedSubBlockEnd.gif            }

转载于:https://www.cnblogs.com/DODONG/archive/2005/10/11/252649.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值