lookupedit控件中用EditValueChanged事件完成省市联动,为什么选择几次省就会出现几次市?(多次选择市之后区也是这个问题),怎么解决?

lookupedit控件中用EditValueChanged事件完成省市联动,为什么选择几次省就会出现几次市?(多次选择市之后区也是这个问题),怎么解决?

图片说明

private void sheng_EditValueChanged(object sender, EventArgs e)
        {
            DataTable shiTb = SqlHelper.Query(" select org_id,gw_organization.`name` as org_name FROM gw_organization where length(org_id)=4 and org_id like '" + sheng.EditValue + "%' ", 0);
            if (shiTb != null)
            {
                this.shi.Properties.ValueMember = "org_id";
                this.shi.Properties.DisplayMember = "org_name";
                this.shi.Properties.DataSource = shiTb;
                this.shi.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
                this.shi.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo(this.shi.Properties.DisplayMember));


                if (!string.IsNullOrEmpty(_addr.City))
                {
                    var InitValue = from r in shiTb.AsEnumerable()
                                    where r.Field<string>("org_name") == _addr.City
                                    let objectArray = new object[]
                                    {
                                    r.Field<string>("org_id")
                                    }
                                    select objectArray;
                    shi.EditValue = InitValue.ToList()[0][0];
                }
            }
        }
private void shi_EditValueChanged(object sender, EventArgs e)
        {
            DataTable quTb = SqlHelper.Query(" select org_id,gw_organization.`name` as org_name FROM gw_organization where length(org_id)=6 and org_id like '" + shi.EditValue + "%' ", 0);
            if (quTb != null)
            {
                this.qu.Properties.ValueMember = "org_id";
                this.qu.Properties.DisplayMember = "org_name";
                this.qu.Properties.DataSource = quTb;
                this.qu.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
                this.qu.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo(this.qu.Properties.DisplayMember));

                if (!string.IsNullOrEmpty(_addr.District))
                {
                    var InitValue = from r in quTb.AsEnumerable()
                                    where r.Field<string>("org_name") == _addr.District
                                    let objectArray = new object[]
                                    {
                                    r.Field<string>("org_id")
                                    }
                                    select objectArray;
                    qu.EditValue = InitValue.ToList()[0][0];
                }
            }
        }

1个回答

Add前 先进行Clear

QwYko
QwYko lookupedit控件怎么清空
8 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐