Dev GridView 内置Lookup组件同时操作编号和名称
Dev GridView 内置Lookup组件同时操作编号和名称
C# Code:
C# 全选
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
gridControl1.DataSource = GetOrder();
//选择,显示编号
repositoryItemLookUpEdit1.DisplayMember = "CustomerCode";// here!
repositoryItemLookUpEdit1.ValueMember = "CustomerCode";
repositoryItemLookUpEdit1.DataSource = GetLookupData();
}
private object GetLookupData()
{
DataTable dt = new DataTable();
dt.Columns.Add("CustomerCode", typeof(String));
dt.Columns.Add("CustomerName", typeof(String));
dt.Rows.Add("ZX", "中兴通讯");
dt.Rows.Add("HW", "华为科技");
dt.Rows.Add("TENCENT", "腾讯科技");
dt.Rows.Add("ALI", "阿里巴巴");
dt.AcceptChanges();
return dt;
}
private object GetOrder()
{
DataTable dt = new DataTable();
dt.Columns.Add("OrderID", typeof(String));
dt.Columns.Add("CustomerCode", typeof(String));
dt.Columns.Add("CustomerName", typeof(String));
dt.Columns.Add("Price", typeof(String));
dt.Rows.Add("ID000001", "HW", "华为科技", 1001.00);
dt.Rows.Add("ID000002", "ZX", "中兴通讯", 99.00);
dt.Rows.Add("ID000003", "TENCENT", "腾讯科技", 120.00);
dt.AcceptChanges();
return dt;
}
private void gridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
if (e.Column.FieldName == "CustomerCode")
{
object dataRow = repositoryItemLookUpEdit1.GetDataSourceRowByKeyValue(e.Value);
object value = (dataRow as DataRowView)["CustomerName"];
gridView1.SetFocusedRowCellValue("CustomerName", value);
}
}
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
扫一扫加作者微信
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网