当前位置:编程学习 > 网站相关 >>

Dev控件,lookUpEdit数据源绑定

//绑定lookUpEdit
        private void BoundData()
        {
            string sql = "select daID,xm,sfzh from baseinfo";
            DataSet ds = Archives.DataAccess.DataSql.Query(sql);
            if (ds != null)
            {
                int rows = ds.Tables[0].Rows.Count;

                lookUpEdit1.EditValue = "daID";
                lookUpEdit1.Properties.ValueMember = "daID";
                lookUpEdit1.Properties.DisplayMember = "xm";
                lookUpEdit1.Properties.DataSource = ds.Tables[0];

                //自适应宽度
                //lookUpEdit1.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;

                //填充列
                lookUpEdit1.Properties.PopulateColumns();

                //设置列属性
                //lookUpEdit1.Properties.Columns[0].Visible = false;
                lookUpEdit1.Properties.Columns[1].Caption = "姓名";
                lookUpEdit1.Properties.Columns[2].Caption = "身份证号";
                lookUpEdit1.Properties.Columns[1].Width = 120;
                lookUpEdit1.Properties.Columns[2].Width = 300;

                //控制选择项的总宽度
                lookUpEdit1.Properties.PopupWidth = 500;

                //列格式设置
                lookUpEdit1.Properties.Columns[0].FormatString = "000000";

                //选择第一项
                lookUpEdit1.ItemIndex = 0;  
            }
        }

        //值改变事件
        private void lookUpEdit1_EditValueChanged(object sender, EventArgs e)
        {
            string daID = this.lookUpEdit1.EditValue.ToString(); //是ookUpEdit.Properties.ValueMember的值
            string xm = this.lookUpEdit1.Text.Trim();
        }

 \



摘自 zouzouol

补充:Web开发 , 其他 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,