今天在窗体中创建了一个列表框,然后又添加了一个按钮,双击该按钮将新元素添加到Items集合中,下面是我输入的代码,使用Items集合的Add()方法
IstPinkFloydAlbums.Items.Add("the division bell");
提示错误,不知道为什么

解决方案 »

  1.   

    listBox1.Items.Add(new   ListItem("", "")); 
      

  2.   

    你的是什么listbox啊,按道理不管是web还是WINFORM的,这个方法都可行。
      

  3.   

    1、WinForm中
    string[] myArray = new string[] { "Red","Green"};
                this.comboBox1.Items.Add("Yellow");
                this.comboBox1.Items.AddRange(myArray);
    2、 ASP.NET中
    ArrayList arrList = new ArrayList();
                arrList.Add("Red");
                arrList.Add("Green");
                arrList.Add("Blue");
                arrList.Add("LightGray");
                this.DropDownList1.DataSource = arrList;
                this.DropDownList1.DataBind();
                this.DropDownList1.Items.Insert(0, "请选择列表项");