将列表框中的一个项目转换为另一个列表框

时间:2016-04-22 08:40:09

标签: c# listbox

我有以下代码将一个项目从(lb1)移动到另一个(lb2)我已经看过很多关于它的例子但是当我这样做时它不会向lb2添加任何项目 我正在使用visual studio并从数据库中读取(如果它有任何区别)。可能有什么不对?

 protected void Button1_Click(object sender, EventArgs e)
    {
        if(lb1.SelectedItem != null)
        {   
            // add the item to the lb2 
            lb2.Items.Add(lb1.SelectedItem);

            // remove the item from the lb1
            lb1.Items.Remove(lb1.SelectedItem);
        }
    }

0 个答案:

没有答案