C#数据刷新实现

需实现选择耗材型号自动改变物料规则和供应商

在这里插入图片描述
在选择耗材型号后发现更改也无法改变物料规则和供应商,发现是Item的值一直叠加,所以取0总是取得第一次的,所以清空item后再赋值就变了

       private void cobGlueType_SelectedIndexChanged(object sender, EventArgs e)
        {
            string strMatType = this.cmbMatType.Text.Trim();

            if (this.cmbMatType.SelectedIndex >= 0)
            {
                DataTable dt = conn.GetGMRule(strMatType);
                foreach (DataRow item in dt.Rows)
                {
                    this.cmbMatRule.Items.Clear();
                    this.cmbVendor.Items.Clear();
                    this.cmbMatRule.Items.Add(item["RULENAME"]);
                    this.cmbVendor.Items.Add(item["GLUEVENDOR"]);
                    cmbMatRule.SelectedIndex = 0;
                    cmbVendor.SelectedIndex = 0;
                    this.dtpEndTime.Value = dtpStartTime.Value.AddDays(Convert.ToInt32(item["EFFECTIVE_DAYS"]));
                }
            }
        }

清空下拉框item中的值

 this.cmbMatRule.Items.Clear();
 this.cmbVendor.Items.Clear();

猜你喜欢

转载自blog.csdn.net/caoguanghui0804/article/details/115252841