this.ListBox2 .Items .Add(this.ListBox1 .Items[0]);
this.ListBox1 .Items .RemoveAt(0);

解决方案 »

  1.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>WebForm2</title>
    <script runat="server" language="C#"> private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面 // 给 ListBox2 和 ListBox3 赋值 if(!IsPostBack)
    {
    for(int i=0;i<4;i++)
    {
    ListBox2.Items.Add("ListBox2_"+i.ToString());
    ListBox3.Items.Add("ListBox3_"+i.ToString());
    }
    } this.Button1.Click += new System.EventHandler(this.Button1_Click);
    this.Button2.Click += new System.EventHandler(this.Button2_Click);
    } // ListBox2 >> ListBox3
    private void Button1_Click(object sender, System.EventArgs e)
    {
    if( ListBox2.SelectedItem != null)
    {
    ListItem tempItem = ListBox2.SelectedItem;
    ListBox2.Items.Remove(tempItem);
    ListBox3.Items.Add(tempItem);
    ListBox3.SelectedIndex = -1;
    }
    }

    // ListBox3 >> ListBox2
    private void Button2_Click(object sender, System.EventArgs e)
    {
    if( ListBox3.SelectedItem != null)
    {
    ListItem tempItem = ListBox3.SelectedItem;
    ListBox3.Items.Remove(tempItem);
    ListBox2.Items.Add(tempItem);
    ListBox2.SelectedIndex = -1;
    }
    }


    </script>
    </HEAD>
    <body>
    <form id="Form1" method="post" runat="server">
    <asp:ListBox id="ListBox2" style="Z-INDEX: 101; LEFT: 88px; POSITION: absolute; TOP: 200px" runat="server"
    Width="96px" Height="128px"></asp:ListBox>
    <asp:ListBox id="ListBox3" style="Z-INDEX: 102; LEFT: 240px; POSITION: absolute; TOP: 200px"
    runat="server" Width="96px" Height="120px"></asp:ListBox>
    <asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 104px; POSITION: absolute; TOP: 152px" runat="server"
    Text=" >> "></asp:Button>
    <asp:Button id="Button2" style="Z-INDEX: 104; LEFT: 256px; POSITION: absolute; TOP: 152px" runat="server"
    Text=" << "></asp:Button>
    </form>
    </body>
    </HTML>
      

  2.   

    脚本实现
    http://lucky.myrice.com/javascriptexam/add_del_Select.htm