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的值