lookUpEdit 绑定数据

北城以北 提交于 2019-12-21 11:25:09

//绑定lookUpEdit

        private void BoundData()   

      {

            string sql = "select daID,xm,sfzh from baseinfo";

            DataSet ds = bga.getTable(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();

        }

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!