更新级联组合框问题C#

更新级联组合框问题C#,c#,winforms,cascade,C#,Winforms,Cascade,我有一个简单的问题 我有一个表单,其中包含两个相关的组合框,但我在更新第二个下拉列表内容时遇到问题 这是密码 private void DiaryForm_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'expensesDataSet.Item' table. You can move, or remove it, as needed. //

我有一个简单的问题 我有一个表单,其中包含两个相关的组合框,但我在更新第二个下拉列表内容时遇到问题

这是密码

  private void DiaryForm_Load(object sender, EventArgs e)
    {
       // TODO: This line of code loads data into the 'expensesDataSet.Item' table. You can move, or remove it, as needed.
      //  this.itemTableAdapter.Fill(this.expensesDataSet.Item);
        using (OleDbConnection con = dbconn.dbconnection())
        {
            ds1 = new ExpensesDataSet();

            string sql = "SELECT * From DiaryView";

            da = new System.Data.OleDb.OleDbDataAdapter(sql, con);
            da.Fill(ds1, "DiaryView");
            NavigateRecords();
            MaxRows = ds1.Tables["DiaryView"].Rows.Count;

            //fill category combobox
           string sqlcat = "SELECT * From Category";

           catda = new System.Data.OleDb.OleDbDataAdapter(sqlcat, con);
           catda.Fill(ds1, "Category");
           catda.Update(ds1, "Category");
           comboBox2.DataSource=ds1.Tables["Category"];
           comboBox2.DisplayMember = "cat_name";
           comboBox2.ValueMember="cat_id";

           //comboBox1.Enabled = false;

        }


    }

 private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
    {
        using (OleDbConnection con = dbconn.dbconnection())
            {
                if (comboBox2.Items.Count > 0)
                {

                    {
                        string cat = comboBox2.SelectedValue.ToString();
                        comboBox1.Enabled = true;
                        int catid = int.Parse(comboBox2.SelectedValue.ToString());
                        string sqlitem = "SELECT * From Item where cat_id = " + catid;
                        catda = new System.Data.OleDb.OleDbDataAdapter(sqlitem, con);

                        this.itemBindingSource.EndEdit();


                        catda.Fill(ds1, "Item");
                        catda.Update(ds1, "Item");
                        comboBox1.DataSource = ds1.Tables["Item"];
                        comboBox1.DisplayMember = "item_name";
                        comboBox1.ValueMember = "item_id";


                    }
                }
            }

    }
共有两个表格: 类别(类别id、类别名称) 项目(项目id、项目名称、类别id)

我能做什么??
plz帮助:)

如果要清除组合框,只需执行以下操作:

combobox1.Items.Clear();

很简单。

对不起,你没有说你的问题是什么,你只是粘贴了你的代码。如果你更努力地使用适当的资本化,避免使用txtspk,你也会增加得到答案的机会。看。我想在填充combobox1之前清除它