comboBox问题。。。
在c# windows应用程序中,我有2个comboBox,一个是选择商品类别,一个是选择商品,现在我想当我选择商品类别时,第二个comboBox将切换到相应的商品类别中的商品,绑定这2个comboBox的程序已经写好。。。我现在用cmb_type_SelectedIndexChanged(object sender, EventArgs e)来做不行哦。。。大家是怎么做的啊?
以下是我的程序(部分):
//【商品类别】下拉列表框下拉选项------
private void selectType()
{
string typeStrSQL = "select * from Type ";
DataTable typeDataTable = dbaccess.SelectDataBase(typeStrSQL);
for (int i = 0; i < typeDataTable.Rows.Count; i++)
this.cmb_type.Items.Add(typeDataTable.Rows[i][1]);
this.cmb_type.SelectedIndex = 0;
}
//-----设置【商品】下拉列表框下拉选项------
private void selectGoods()
{
string Typename = this.cmb_type.Text.Trim();
string TypeID = " ";
string Typestrsql = "select * from Type where typename= ' " + Typename + " ' ";
DataTable typeDataTable = dbaccess.SelectDataBase(Typestrsql);
TypeID = typeDataTable.Rows[0][0].ToString();
string typeStrSQL = "select * from Good where TypeID= ' " + TypeID + " ' ";
DataTable type_DataTable = dbaccess.SelectDataBase(typeStrSQL);
for (int i = 0; i < type_DataTable.Rows.Count; i++)
this.cmb_goods.Items.Add(type_DataTable.Rows[i][1]);
this.cmb_goods.SelectedIndex = 0;
}
//主程序,初始化
public jinhuo_add(bool blShowToolBar)