Dev 控件lookUpEdit的数据绑定及其获取从UI界面赋给lookupedit的值

lookUpEdit1数据绑定:
           lookUpEdit1.Properties.DataSource = dt;
           lookUpEdit1.Properties.Columns.Add(new LookUpColumnInfo("DayPropName", "日期类型"));
           lookUpEdit1.Properties.DisplayMember = "DayPropName";
           lookUpEdit1.Properties.ValueMember = "DayProp";
           lookUpEdit1.Properties.TextEditStyle = TextEditStyles.DisableTextEditor; //默认不可编辑
           lookUpEdit1.ItemIndex = 0; //默认显示第一行

 

把GridView中的数据绑定到lookUpEdit1的数据动态绑定(随着导航条变化):

DataRow dr = gridView_SpecialDay.GetFocusedDataRow();
            if (dr != null)
            {
                string DayPropstr = dr["DayProp"].ToString();//(是ValueMember的值)
                string Adatestr = dr["ADate"].ToString();
                if (Adatestr != "")
                {
                    dateEdit_Day.EditValue = Convert.ToDateTime(Adatestr).ToString("yyyy/MM/d");
                }
                if (DayPropstr != "")
                {
                    lookUpEdit1.EditValue=byte.Parse( DayPropstr); //要与数据库中的类型相同(注:绑定lookupEdit)(数据库中的类型是tinyint(无符号整型与.Net中的byte类型对应))
                }
            }

  lookUpEdit1.EditValue不是字符类型; lookUpEdit1.text是字符类型

3.获取 中界面赋予的 lookUpEdit1值

spmodel.DayProp =int.Parse( lookUpEdit2_DayProp.EditValue.ToString().Trim()); //实质是获取到了ValueMember的值

posted @ 2012-11-07 16:15  郑松涛  阅读(5067)  评论(0编辑  收藏  举报