如题目 代码?
StrSql = "delete QiPuName where 表名 = " + "'" + this.listBox2.Text + "'";
            myConnection.Open();
            this.myCmd1 = new SqlCommand(StrSql, myConnection);
            this.DataSet1.Clear();
            string strsql2 = "select * from QiPuName";
            this.sqlDataAdapter1 = new SqlDataAdapter(strsql2,myConnection);
            this.sqlDataAdapter1.Fillthis.DataSet);
            int intNumber2 = myCmd1.ExecuteNonQuery();
            this.listBox2.Refresh();
            myConnection.Close();

解决方案 »

  1.   

    删除后 剩下的item都不显示了
      

  2.   

    Refresh之 后重新绑定一下也可以!
      

  3.   

    this.listBox2.DataSource = DataSet;
    this.listBox2.DataBind();
    要重新邦定也可以更新。
      

  4.   

    如果你是WinFrom程序,去掉Refresh()就可以了,你的DataSet改變後,listBox2會自動更新。
      

  5.   

    我的是winform vs2005 
    listBox没有databind()方法??就是不知道怎么绑定 
    去掉refresh()不会自动更新?
    大家帮忙动手试下?就一两个控件又不麻烦 成功了再说?
    谢谢大家了啊 郁闷啊
      

  6.   

    你每次删除后就再重新绑定一下:举个例子吧..        private void button1_Click(object sender, EventArgs e)
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("delete from studentDetails where sname='jiajun'", con);
                cmd.ExecuteNonQuery();
                con.Close();
                this.DataBind();
            }        private void Form1_Load(object sender, EventArgs e)
            {
                this.DataBind();
            }
            private void DataBind()
            {
                DataSet ds=new DataSet ();
                SqlDataAdapter sda = new SqlDataAdapter(); 
                sda.SelectCommand = new SqlCommand("select * from studentDetails", con);
                sda.Fill(ds, "student");
                this.listBox1 .DataSource = ds.Tables["student"];
                this.listBox1.DisplayMember = "sname";
            }