for (int i = 0; i < this.listBox1.Items.Count - 1; i++)
            {
                if (this.listBox1.Items[i].Selected == true)
                {
                    this.listBox1.Items.RemoveAt(i);
                }
            }listBox1.Items[i].的后面只会显示:四个属性Equals、GetHashCode、GetType、ToString;没有Selected的属性。 
这是为什么呢?

解决方案 »

  1.   

    ListBox.SelectedIndex 属性 
      
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 
    http://feiyun0112.cnblogs.com/
      

  2.   

    你是要删除吧选中的那个吧,这样就可以了
    this.listBox1.Items.RemoveAt(this.listBox1.SelectedIndex);
      

  3.   

    给你举个例子 listbox连动protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
    { ListBox2.Items.Clear();
    string path = ListBox1.SelectedItem.Value;
    string[] fileName = Directory.GetDirectories(path);

    foreach (string f in fileName)
    {
    string temp;
    temp = f.Substring(3);
    ListBox2.Items.Add(temp);
    }

    }
      

  4.   

    如果这么做不好用.那就把listbox属性里的AutoPostBack改为true;
      

  5.   

    this.listBox1.Items[i]是Object类型的,不包括Selected属性。
    获取所有ListBox的选中的Items,要使用ListBox.SelectedItems 属性