晕呼呼。
不写代码了
楼主想想吧。
用for循环的--来remove左边的listbox的项
同时加到另一个listbox里

解决方案 »

  1.   

    private void JB_But1_Click(object sender, System.EventArgs e)
    {
    ListItem item=new ListItem(ViewState["name"].ToString(),ViewState["id"].ToString());
    for(int i=0;i<JB_ListBox2.Items.Count ;i++)
    {
    if(JB_ListBox2.Items[i].Value==item.Value)
    {
    return ;
    }
    }
    this.JB_ListBox2.Items.Add(item);
    }
      

  2.   

    ListBox1.Items.Remove(ListBox2.SelectedItem.Text);這樣嗎?
      

  3.   

    ListBox1.Items.RemoveAt(ListBox1.SelectedIndex);
      

  4.   

    Simple Demo:<%@ Page Language="C#" AutoEventWireup="true"  %><%--http://community.csdn.net/Expert/TopicView3.asp?id=5619363--%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">    protected void Button1_Click(object sender, EventArgs e)
        {
            SwapListBox(ListBox1, ListBox2);       
        }    protected void Button2_Click(object sender, EventArgs e)
        {
            SwapListBox(ListBox2, ListBox1);
        }    private void SwapListBox(ListBox src, ListBox dst)
        {
            for (int i = 0; i < src.Items.Count; ) {
                ListItem item = src.Items[i];
                if (item.Selected) {
                    src.Items.Remove(item);
                    item.Selected = dst.SelectionMode == ListSelectionMode.Multiple ? item.Selected : false;
                    dst.Items.Add(item);
                    continue;
                }
                i++;
            }
        }
    </script><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Double ListBox</title>
        <script type="text/javascript">
       
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <div style="float:left">
            <asp:ListBox ID="ListBox1" BorderWidth="1" runat="server" SelectionMode="Multiple">
                <asp:ListItem Value="Item1">Item1</asp:ListItem>
                <asp:ListItem Value="Item2">Item2</asp:ListItem>
                <asp:ListItem Value="Item3">Item3</asp:ListItem>
                <asp:ListItem Value="Item4">Item4</asp:ListItem>
            </asp:ListBox>
        </div>
        <div style="float:left;vertical-align:middle;">
            <asp:Button ID="Button1" runat="server" Text=">>" OnClick="Button1_Click" />
            <br />
            <asp:Button ID="Button2" runat="server" Text="<<" OnClick="Button2_Click" />
        </div>
        <div>
           <asp:ListBox ID="ListBox2" BorderWidth="1" runat="server">            
            </asp:ListBox>
        </div>
        </div>
        </form>
    </body>
    </html>
      

  5.   

    private void Button1_Click(object sender, System.EventArgs e)
    {
    if(ListBox1.SelectedItem!=null)
    {
    ListBox2.Items.Add(ListBox1.SelectedValue);
    ListBox1.Items.Remove(ListBox1.SelectedValue);
    }
    } private void Button2_Click(object sender, System.EventArgs e)
    {
    if(ListBox2.SelectedItem!=null)
    {
    ListBox1.Items.Add(ListBox2.SelectedValue);
    ListBox2.Items.Remove(ListBox2.SelectedValue);
    }
    }